Module Mtime.SpanSource

Monotonic time spans.

Monotonic time spans

Sourcetype t = span
Sourceval zero : span

zero is a span of 0ns.

Sourceval one : span

one is a span of 1ns.

Sourceval min_span : span

min_span is zero.

Sourceval max_span : span

max_span is 264-1ns.

Predicates

Sourceval equal : span -> span -> bool

equal span span' is true iff span and span' are equal.

Sourceval compare : span -> span -> int

compare span span' orders spans by increasing duration.

Arithmetic

Sourceval add : span -> span -> span

add span span' is span + span'.

Warning. Rolls over on overflow.

Sourceval abs_diff : span -> span -> span

abs_diff span span' is the absolute difference between span and span'.

Durations

Sourceval (*) : int -> span -> span

n * dur is n times duration dur.

Warning. Does not check for overflow or that n is positive.

Sourceval ns : span

ns is a nanosecond duration, 1·10-9s.

Sourceval us : span

us is a microsecond duration, 1·10-6s.

Sourceval ms : span

ms is a millisecond duration, 1·10-3s.

Sourceval s : span

s is a second duration, 1s.

Sourceval min : span

min is a minute duration, 60s.

Sourceval hour : span

hour is an hour duration, 3600s.

Sourceval day : span

day is a day duration, 86'400s.

Sourceval year : span

year is a Julian year duration (365.25 days), 31'557'600s.

Converting

Sourceval to_uint64_ns : span -> int64

to_uint64_ns span is span as an unsigned 64-bit integer nanosecond span.

Sourceval of_uint64_ns : int64 -> span

of_uint64_ns u is the unsigned 64-bit integer nanosecond span u as a span.

Sourceval to_ns : span -> float

to_ns span is span in nanoseconds (1e-9s).

Sourceval to_us : span -> float

to_us span is span in microseconds (1e-6s).

Sourceval to_ms : span -> float

to_ms span is span in milliseconds (1e-3s).

Sourceval to_s : span -> float

to_s span is span in seconds.

Sourceval to_min : span -> float

to_min span is span in SI-accepted minutes (60s).

Sourceval to_hour : span -> float

to_hour span is span in SI-accepted hours (3600s).

Sourceval to_day : span -> float

to_day span is span in SI-accepted days (24 hours, 86400s).

Sourceval to_year : span -> float

to_year span is span in Julian years (365.25 days, 31'557'600s).

Formatters

Sourceval pp : Format.formatter -> span -> unit

pp_span ppf span formats an unspecified representation of span on ppf. The representation is not fixed-width, depends on the magnitude of span and uses locale independent standard time scale abbreviations.

Sourceval pp_float_s : Format.formatter -> float -> unit

pp_float_s formats like pp does but on a floating point seconds time span value (which can be negative).

Sourceval dump : Format.formatter -> t -> unit

dump ppf span formats an unspecified raw representation of span on ppf.