System
Quick Reference
| Name | Type | Description |
|---|---|---|
| GetTime | Shared | Returns a monotonic clock in milliseconds. |
Shared Functions
GetTime
Returns the time in milliseconds from a clock that only ever moves forward. It is the clock the threads and timers run on, so it is the right one for measuring how long something took or for checking whether a pause is over.
int milliseconds = System.GetTime()
info
The value has no meaning on its own; only the difference between two readings does. It is not the
time of day and not related to the value on another machine. For the date and time use the
language's own functions (os.time, Date).
Example:
- Lua
- JavaScript
- Squirrel (deprecated)
local start = System.GetTime()
local rows = Database.Select("SELECT * FROM users", {})
Console.Log("Query took " .. (System.GetTime() - start) .. " ms.")
const start = System.GetTime();
const rows = Database.Select("SELECT * FROM users", []);
Console.Log("Query took " + (System.GetTime() - start) + " ms.");
local start = System.GetTime();
local rows = Database.Select("SELECT * FROM users", []);
Console.Log("Query took " + (System.GetTime() - start) + " ms.");