RosettaCodeData/Task/Time-a-function/Agena/time-a-function.agena

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