RosettaCodeData/Task/Time-a-function/Pluto/time-a-function.pluto

15 lines
344 B
Plaintext

do -- Time a function
local function timeFunction( f : function ) : number
local startTime = os.micros()
f()
return os.micros() - startTime
end
local function toBeTimed() : void
os.sleep( 1234 ) -- sleep 1.234 seconds
end
print( $"{ timeFunction( toBeTimed ) / 1_000_000 } seconds" )
end