Skip to content

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 no os, so it uses GetGameTimer() (millisecond resolution).
  • stop returns the elapsed milliseconds, or nil (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.