Enum core.time.ClockType
What type of clock to use with MonoTime
/ MonoTimeImpl
or
std
. They default to ClockType
,
and most programs do not need to ever deal with the others.
enum ClockType
: int { ... }
The other ClockType
s are provided so that other clocks provided by the
underlying C, system calls can be used with MonoTimeImpl
or
std
without having to use the C API directly.
In the case of the monotonic time, MonoTimeImpl
is templatized on
ClockType
, whereas with std
, its a runtime
argument, since in the case of the monotonic time, the type of the clock
affects the resolution of a MonoTimeImpl
object, whereas with
std
, its resolution is always hecto-nanoseconds
regardless of the source of the time.
ClockType
, ClockType
, and ClockType
work with both Clock
and MonoTimeImpl
.
ClockType
only works with Clock
. The others only
work with MonoTimeImpl
.
Enum members
Name | Description |
---|---|
bootTime
|
Linux,OpenBSD-Only
Uses |
coarse
|
Use the coarse clock, not the normal one (e.g. on Linux, that would be
CLOCK_REALTIME_COARSE instead of CLOCK_REALTIME for
clock_gettime if a function is using the realtime clock). It's
generally faster to get the time with the coarse clock than the normal
clock, but it's less precise (e.g. 1 msec instead of 1 usec or 1 nsec).
Howeover, it is guaranteed to still have sub-second precision
(just not as high as with ClockType ).
On systems which do not support a coarser clock,
Most programs should not use the coarse clock, exactly because it's less precise, and most programs don't need to get the time often enough to care, but for those rare programs that need to get the time extremely frequently (e.g. hundreds of thousands of times a second) but don't care about high precision, the coarse clock might be appropriate. Currently, only Linux and FreeBSD/DragonFlyBSD support a coarser clock, and on other
platforms, it's treated as |
normal
|
Use the normal clock. |
precise
|
Uses a more precise clock than the normal one (which is already very
precise), but it takes longer to get the time. Similarly to
ClockType , if it's used on a system that does not support a
more precise clock than the normal one, it's treated as equivalent to
ClockType .
Currently, only FreeBSD/DragonFlyBSD supports a more precise clock, where it uses
|
processCPUTime
|
Linux,OpenBSD,Solaris-Only
Uses |
raw
|
Linux-Only
Uses |
second
|
Uses a clock that has a precision of one second (contrast to the coarse
clock, which has sub-second precision like the normal clock does).
FreeBSD/DragonFlyBSD are the only systems which specifically have a clock set up for
this (it has So, the primary difference between |
threadCPUTime
|
Linux,OpenBSD,Solaris-Only
Uses |
uptime
|
DragonFlyBSD,FreeBSD,OpenBSD-Only
Uses |
uptimeCoarse
|
FreeBSD-Only
Uses |
uptimePrecise
|
FreeBSD-Only
Uses |
Authors
Jonathan M Davis and Kato Shoichi