Measure of exucution time
Posted: Fri Apr 07, 2017 5:40 pm
Hello !
How i can measure the execution time of some function ? using a tmr ?
Max
How i can measure the execution time of some function ? using a tmr ?
Max
-->
Open Community Forum for ESP8266, Come share Arduino and IoT (Internet of Things)
https://www.esp8266.com/
function profile(name)
local start = tmr.now()
_G[name]()
local delta = tmr.now() - start
print(name .. " needs " .. (delta / 1000) .. " ms")
end
function 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