Stats.As_ctxModule for manipulating statistics as a context using algebraic effects (that are hidden). All calls to any function in this module should happen only inside a function wrapped with with_stats, ensuring that the statistics are properly passed around.
val with_stats : unit -> (unit -> 'a) -> 'a with_statswith_stats () f runs function f and handles effects raised by the functions of this module such as push_entry, and returns a record containing the result of executing f together with the obtained statistics.
with_stats_ignored () f runs function f and handles effects raised by the functions of this module, but ignores their effect. This is to be used when the user does not wish to pay the (minor) performance cost of stats bookkeeping.
with_stats_dumped () f runs function f and handles effects raised by the functions of this module such as push_entry, and dumps the stats to the file specified by the current Config.output_stats if it is set, or ignores them otherwise.
val push_entry : string -> stat_entry -> unitpush_entry name entry adds the given statistic entry under the given name name to the current statistics context.
add_time_of_to name f measures the execution time of function f in seconds, and adds it as a float statistic under the given name name. It returns the result of executing f.
push_str name s adds the given string s as a single entry in a string sequence statistic under the given name name.
val push_binding : string -> string -> stat_entry -> unitpush_binding name key entry adds the given statistic entry under the given key key in a map statistic under the given name name.
push_string_binding name key s adds the given string s as a single entry in a string sequence statistic under the given key key in a map statistic under the given name name.
val get_copy : unit -> tget_copy () retrieves a copy of the statistics aggregated in the current environment