15 lines
344 B
Text
15 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
|