sys.clock()

Returns the current elapsed time, that can be used for time-interval measurements.

Return value

This function returns the current elapsed time in millisecond. Luart uses a high performance counter if available, or the current elapsed time since the system has started otherwise.

Example

function benchmark(name, func, ...) local start = sys.clock() func(...) local finish = sys.clock() print(name.." benchmark : "..tostring(finish-start).."ms") end function fibonacci(n) local a, b = 0, 1 for i = 1, n do a, b = b, a + b end return a end benchmark("fibonacci", fibonacci, 5000000)