Module Note_brr_kit.TimeSource

Monotonic time.

Time span

Sourcetype span = float

The type for time spans, in seconds. FIXME move to ms.

Passing time

Sourceval elapsed : unit -> span

elapsed () is the number of seconds elapsed since the beginning of the program.

Tick events

Sourceval tick : span -> span Note.event

tick span is an event that occurs once in span seconds with the value span - span' where span' is the actual delay performed by the system.

Note. Since the system may introduce delays you cannot assume that two different calls to tick will necessarily yield two non-simultaneous events.

Sourceval delay : span -> (unit -> unit) -> unit

delay span f calls f after span seconds.

Counters

Sourcetype counter

The type for time counters.

Sourceval counter : unit -> counter

counter () is a counter counting time from call time on.

Sourceval counter_value : counter -> span

counter_value c is the current counter value in seconds.

Pretty printing time

Sourceval to_jstr : [ `S | `Ms | `Mus ] -> span -> Jstr.t