RosettaCodeData/Task/Time-a-function/Agena/time-a-function.agena
2026-02-01 16:33:20 -08:00

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