SysTime

From Garry's Mod
Jump to: navigation, search
 SysTime( )

Contents

Description

Returns a highly accurate time in seconds since the start up, ideal for benchmarking.

Returns

number

Uptime of the server.

Examples

Example

Prints the runtime

print(SysTime())

Output:

1654.4422888037

Examples

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.
Personal tools
Navigation