Garry's Mod Wiki

SysTime

  number SysTime()

Description

Returns a highly accurate time in seconds since the start up, ideal for benchmarking. Unlike RealTime, this value will be updated any time the function is called, allowing for sub-think precision.

Returns

1 number
Uptime of the server.

Example

Prints the runtime

Output: 1654.4422888037

Example

Typical usage of this function for benchmarking

local SysTime = SysTime local Distance = FindMetaTable("Vector").Distance local vec1 = Vector(1, 2, 3) local vec2 = Vector(13, 26, -10) local count = 10000 local StartTime = SysTime() for i = 1, count do -- Repeat an action 10,000 times to check how long it takes on average -- Example action: Distance(vec1 , vec2) end local EndTime = SysTime() local TotalTime = EndTime - StartTime local AverageTime = TotalTime / count print("Total: " .. TotalTime .. " seconds. Average: " .. AverageTime .. " seconds.")
Output:
Total: 0.0099969995115998 seconds. Average: 9.9969995115998e-07 seconds.