Current Lua downloadable firmware will be posted here

User avatar
By Frank Buss
#64968 You can profile a function like this:
Code: Select allfunction profile(name)
   local start = tmr.now()
   _G[name]()
   local delta = tmr.now() - start
   print(name .. " needs " .. (delta / 1000) .. " ms")
end


Example:

Code: Select allfunction longTime()
   local sum = 0
   for i = 1, 100000, 1 do
      sum = sum + i
   end
   print(sum)
end

> profile("longTime")
5000050000
longTime needs 474.855 ms


Resolution is one microsecond. Note the 32 bit counter wraps from time to time and might then show a really big number :D