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