14 lines
359 B
Text
14 lines
359 B
Text
scope # Time a function
|
|
|
|
local proc timeFunction( f :: procedure ) :: number
|
|
local startTime := os.clock();
|
|
f();
|
|
return os.clock() - startTime # execution time in milliseconds
|
|
end;
|
|
|
|
local proc toBeTimed()
|
|
os.wait( 1.234 ) # sleep 1.234 seconds
|
|
end
|
|
|
|
print( timeFunction( toBeTimed ) / 1000, " seconds" )
|
|
end
|