tm.benchmark
Named stopwatches that print the elapsed time. Shared.
lua
tm.benchmark.start('load')
-- work
local ms = tm.benchmark.stop('load') -- logs "[BENCHMARK] Process 'load' took 12.345 milliseconds." and returns 12.345- The server measures with
os.clock()(sub millisecond). The client has noos, so it usesGetGameTimer()(millisecond resolution). stopreturns the elapsed milliseconds, ornil(with a warning) when no stopwatch with that name was started.- Output goes through
tm.log.info/tm.log.warn, so it carries the resource prefix.