Clocks v0.1.0

Source
Performance counters, system time and tick counts.

QueryPerformanceCounter

pub extern func QueryPerformanceCounter(count: *var int64) -> int32

Reads the monotonic performance counter. Writes the current count and returns nonzero. It cannot fail on any system this package supports, and the count is guaranteed not to go backwards — unlike the wall clock, which can. The unit is whatever QueryPerformanceFrequency reports and is not seconds.

See also: https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter

Source

Parameters

NameTypeDescription
count*var int64receives the counter's current value

Returns: non-zero on success

QueryPerformanceFrequency

pub extern func QueryPerformanceFrequency(frequency: *var int64) -> int32

Reads how many performance-counter ticks make one second. Fixed while the system runs, so a caller reads it once rather than per measurement.

See also: https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency

Source

Parameters

NameTypeDescription
frequency*var int64receives the counter's fixed frequency, in counts per second

Returns: non-zero on success

GetSystemTimePreciseAsFileTime

pub extern func GetSystemTimePreciseAsFileTime(time: *var FileTime)

Reads the current wall-clock time at the highest resolution the system offers. Writes 100-nanosecond intervals since January 1, 1601 UTC. The plain GetSystemTimeAsFileTime is cheaper and coarser, advancing only at the scheduler's tick.

See also: https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime

Source

Parameters

NameTypeDescription
time*var FileTimereceives the reading

GetSystemTimeAsFileTime

pub extern func GetSystemTimeAsFileTime(time: *var FileTime)

Reads the current wall-clock time at the system tick's resolution.

See also: https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime

Source

Parameters

NameTypeDescription
time*var FileTimereceives the reading

GetLocalTime

pub extern func GetLocalTime(time: *SystemTime)

Retrieves the current local date and time.

See also: https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getlocaltime

Source

Parameters

NameTypeDescription
time*SystemTimereceives the reading

GetSystemTime

pub extern func GetSystemTime(time: *SystemTime)

Retrieves the current system date and time in Coordinated Universal Time (UTC) format.

See also: https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtime

Source

Parameters

NameTypeDescription
time*SystemTimereceives the reading

GetTickCount64

pub extern func GetTickCount64() -> uint64

Retrieves the number of milliseconds that have elapsed since the system was started.

See also: https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount64

Source

Returns: milliseconds since the system started