Module Mtime
Monotonic time values.
Mtime
has platform independent support for monotonic wall-clock time. This time increases monotonically and is not subject to operating system calendar time adjustments.
Time spans represent non-negative monotonic time spans between two monotonic clock readings. Timestamps represent system-relative monotonic timestamps, their absolute value is meaningless but they can be compared across the processes of an operating system run.
Mtime_clock
provides access to a system monotonic clock.
%%VERSION%% — homepage
Monotonic time spans
type span
The type for non-negative monotonic time spans. They represent the difference between two monotonic clock readings. If the platform's clock has nanosecond resolution the representation guarantees that the function
Mtime_clock.elapsed
can measure up to approximatively 584 Julian year spans before silently rolling over (unlikely since this is in a single program run).
module Span : sig ... end
Monotonic time spans.
Monotonic timestamps
Note. Only use timestamps if you need inter-process time correlation, otherwise prefer Mtime_clock.elapsed
and counters.
type t
The type for monotonic timestamps relative to an indeterminate system-wide event (e.g. last startup). Their absolute value has no meaning but can be used for inter-process time correlation.
val to_uint64_ns : t -> int64
to_uint64_ns t
ist
as an unsigned 64-bit integer nanosecond timestamp. The absolute value is meaningless.
val of_uint64_ns : int64 -> t
to_uint64_ns t
ist
is an unsigned 64-bit integer nanosecond timestamp as a timestamp.Warning. Timestamps returned by this function should only be used with other timestamp values that are know to come from the same operating system run.
Predicates
Arithmetic
val span : t -> t -> span
span t t'
is the span betweent
andt'
regardless of the order betweent
andt'
.
Pretty printing
val pp : Stdlib.Format.formatter -> t -> unit
pp ppf t
printst
as an unsigned 64-bit integer nanosecond timestamp. Note that the absolute value is meaningless.
val dump : Stdlib.Format.formatter -> t -> unit
dump ppf t
prints an unspecified raw representation oft
onppf
.
Time scale conversion
The following convenience constants relate time scales to seconds. Used as multiplicands they can be used to convert these units to and from seconds.
The constants are defined according to SI prefixes on seconds and accepted non-SI units. Years are counted in Julian years (365.25 SI-accepted days) as defined by the International Astronomical Union (IAU).