package affect
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=b328f6696e60c489da8cc2e8fad0537ca6634a39fc0c5de5840d4f98561f110617ef79ba8285ee8427dd99908c6b3d39114973598cddc5ded91abcce3b91b9a6
doc/affect.unix/Affect_unix/Mtime/index.html
Module Affect_unix.MtimeSource
Monotonic time.
This time is measured by sampling this clock. It increases monotonically and, in contrast to Ptime, is not subject to operating system calendar time adjustments.
Time spans
Waiting
Warning. This relies on an Unix.unblocker being setup on the executing domain.
wait_for span blocks the caller until a minimum amount of span time has elapsed on the monotonic clock. The actual supported resolution is unspecified and may depend on scheduling but millisecond waits should be reasonably precise. Use observe_wait_for to measure the overshoot.
observe_wait_for is like wait_for but returns the actual amount of monotonic time that elapsed on the monotonic clock between the call and when it returned.
Actions
wait_for' span tag is the action for wait_for. The action invocation enables and synchronizes with tag after a minimum amount of span monotonic time has elapsed on the monotonic clock.
Counters
The type for monotonic wall-clock time counters.
count c is the amount of time that has elapsed on the monotonic clock since c was created.
elapsed () is the amount of time that has elapsed on the monotonic clock since the beginning of the program.
Timestamps
Note. Only use timestamps if you need inter-process time correlation, otherwise prefer elapsed and counters to measure time.
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.
now () is the current system-relative timestamp on the monotonic clock. Its absolute value is meaningless.
Predicates
is_earlier t ~than is true if and only if t occurred strictly before than.
is_later t ~than is true if and only if t occurred strictly after than.
Arithmetic
span t0 t1 is the span between t0 and t1 regardless of the order between t0 and t1.
add_span t s is the timestamp s units later than t or None if the result overflows.
sub_span t s is the timestamp s units earlier than t or None if overflows.
Converting
to_uint64_ns t is t as an unsigned 64-bit integer nanosecond timestamp. The absolute value is meaningless.
to_uint64_ns t is t 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.
pp is a formatter for timestamps.
The monotonic clock
- Linux uses
clock_gettimewith CLOCK_BOOTTIME. This means that sleep time is taken into account. - Platforms with a POSIX clock use
clock_gettimewith CLOCK_MONOTONIC. - MacOS >= 10.12 uses
mach_continous_time, sleep time is taken into account. For MacOS < 10.12,mach_absolute_timeis used, sleep time is not taken into account. - Windows uses Performance counters.