RosettaCodeData/Task/Time-a-function/Pluto/time-a-function.pluto
2025-08-11 18:05:26 -07:00

14 lines
344 B
Text

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