Clock
in package
The clock provides utility methods for measuring and working with high resolution time.
Table of Contents
Methods
- diff() : ClockNanoseconds
- Returns the time difference between two timestamps in nanoseconds.
- diff64() : int
- Returns the difference between two timestamps in nanoseconds as a single 64bit integer.
- now() : ClockNanoseconds
- Returns the current time in nanoseconds.
- now64() : int
- Returns the current time in nanoseconds as a single 64 bit integer.
- sleep() : void
- Sleep for the given amount of nanoseconds.
- sleep64() : void
- Sleep for the given amount of nanoseconds using a single 64 bit integer.
Methods
diff()
Returns the time difference between two timestamps in nanoseconds.
public
static diff(ClockNanoseconds $t1, ClockNanoseconds $t2) : ClockNanoseconds
The returned value is always positive, meaning the order of the arguments does not matter.
Parameters
- $t1 : ClockNanoseconds
- $t2 : ClockNanoseconds
Return values
ClockNanosecondsdiff64()
Returns the difference between two timestamps in nanoseconds as a single 64bit integer.
public
static diff64(ClockNanoseconds $t1, ClockNanoseconds $t2) : int
Note this does only work for timestamps that are less than 2^63 nanoseconds apart.
Parameters
- $t1 : ClockNanoseconds
-
The first timestamp.
- $t2 : ClockNanoseconds
-
The second timestamp.
Return values
intnow()
Returns the current time in nanoseconds.
public
static now() : ClockNanoseconds
Return values
ClockNanosecondsnow64()
Returns the current time in nanoseconds as a single 64 bit integer.
public
static now64() : int
Return values
intsleep()
Sleep for the given amount of nanoseconds.
public
static sleep(ClockNanoseconds $nanoseconds) : void
Parameters
- $nanoseconds : ClockNanoseconds
sleep64()
Sleep for the given amount of nanoseconds using a single 64 bit integer.
public
static sleep64(int $nanoseconds) : void
Parameters
- $nanoseconds : int