File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -365,4 +365,9 @@ export const osApi = new LuaTable({
365365 return luaFormatTime ( fmt , d , utc ) ;
366366 } ,
367367 ) ,
368+
369+ // Returns an approximation of CPU time used by the program in seconds.
370+ clock : new LuaBuiltinFunction ( ( _sf ) : number => {
371+ return performance . now ( ) / 1000.0 ;
372+ } ) ,
368373} ) ;
Original file line number Diff line number Diff line change @@ -168,3 +168,15 @@ assert(type(err) == "string")
168168
169169-- Repeated specifiers
170170assertEquals (os.date (" !%Y%Y" , ts ), " 20062006" )
171+
172+ -- os.clock
173+ -- Returns a number (seconds)
174+ assert (type (os.clock ()) == " number" )
175+
176+ -- Must be non-negative
177+ assert (os.clock () >= 0 )
178+
179+ -- Monotonically non-decreasing
180+ local c1 = os.clock ()
181+ local c2 = os.clock ()
182+ assert (c2 >= c1 )
You can’t perform that action at this time.
0 commit comments