if (FALSE) {
# Debugger in "one-shot" mode
lua_mode(debug = "on",
sum <- lua("
local s = 0
for i = 1,10 do
s = s + i
end
return s
")
)
# Profiler in "switch on / switch off" mode
lua_mode(profile = TRUE)
pointless_computation = lua_func(
"function()
local s = startval
for i = 1,10^8 do
s = math.sin(s)
s = math.exp(s^2)
s = s + 1
end
return s
end")
lua("startval = 100")
pointless_computation()
lua_mode(profile = FALSE)
lua_profile()
# Turn off JIT and turn it on again
lua_mode(jit = "off")
lua_mode(jit = "on")
}
Run the code above in your browser using DataLab