Module Time_measurement.Make

A time measurement tool that uses the given clock C to measure the time, stores resulting measurements inside the given state S and publishes stored measurements using the publisher P.

Parameters

module S : State.S with type elt := Measurement.t
module P : Publisher.S
module C : Clock.S

Signature

val duration : Measurement.key -> (unit -> 'a) -> 'a

duration key thunk mesures the time taken to run the given thunk, binds the resulting time measurement with the given key and stores it in the batch. It will then evaluate in the result of the thunk.

val duration_lwt : Measurement.key -> (unit -> 'a Lwt.t) -> 'a Lwt.t

Same as duration, but waits for the thunk's resulting promise to be resolved in order to properly measure time when using Lwt.

val timestamp_pre : Measurement.key -> (unit -> 'a) -> 'a

timestamp_pre key thunk mesures the current time, binds the resulting time measurement with the given key and stores it in the batch. It will then execute the given thunk and evaluates in its result.

val flush : unit -> unit Lwt.t

flush () cleans the batch and emits an event log that will display all measured times collected within the batch.