Safe Haskell | Safe |
---|---|
Language | Haskell98 |
High-resolution, realtime clock and timer functions for Posix
Documentation
Clock types. A clock may be system-wide (that is, visible to all processes) or per-process (measuring time that is meaningful only within a process). All implementations shall support CLOCK_REALTIME. (The only suspend-aware monotonic is CLOCK_BOOTTIME on Linux.)
Monotonic | The identifier for the system-wide monotonic clock, which is defined as
a clock measuring real time, whose value cannot be set via
|
Realtime | The identifier of the system-wide clock measuring real time. For this clock, the value returned by getTime represents the amount of time (in seconds and nanoseconds) since the Epoch. |
ProcessCPUTime | The identifier of the CPU-time clock associated with the calling process. For this clock, the value returned by getTime represents the amount of execution time of the current process. |
ThreadCPUTime | The identifier of the CPU-time clock associated with the calling OS thread. For this clock, the value returned by getTime represents the amount of execution time of the current OS thread. |
MonotonicRaw | (since Linux 2.6.28; Linux-specific) Similar to CLOCK_MONOTONIC, but provides access to a raw hardware-based time that is not subject to NTP adjustments or the incremental adjustments performed by adjtime(3). |
Boottime | (since Linux 2.6.39; Linux-specific) Identical to CLOCK_MONOTONIC, except it also includes any time that the system is suspended. This allows applications to get a suspend-aware monotonic clock without having to deal with the complications of CLOCK_REALTIME, which may have discontinuities if the time is changed using settimeofday(2). |
MonotonicCoarse | (since Linux 2.6.32; Linux-specific) A faster but less precise version of CLOCK_MONOTONIC. Use when you need very fast, but not fine-grained timestamps. |
RealtimeCoarse | (since Linux 2.6.32; Linux-specific) A faster but less precise version of CLOCK_REALTIME. Use when you need very fast, but not fine-grained timestamps. |
TimeSpec structure
getTime :: Clock -> IO TimeSpec Source
The getTime
function shall return the current value for the
specified clock.
getRes :: Clock -> IO TimeSpec Source
The getRes
function shall return the resolution of any clock.
Clock resolutions are implementation-defined and cannot be set
by a process.
diffTimeSpec :: TimeSpec -> TimeSpec -> TimeSpec Source
Compute the absolute difference.
timeSpecAsNanoSecs :: TimeSpec -> Integer Source
TimeSpec as nano seconds.