RosettaCodeData/Task/Time-a-function/Lua/time-a-function.lua

15 lines
256 B
Lua

function bench(Function, ...)
local t = os.time()
local clock1 = os.clock()
Function(...)
local c = os.clock()-clock1
return os.time()-t, c
end
function sleep(n)
local start = os.time()
repeat until os.time()-start==n
end
print( bench(sleep, 2) )