Legend:
Library
Module
Module type
Parameter
Class
Class type
All Incr_map functions take an optional instrumentation parameter that has type Instrumentation.t. A value of this type is a record containing a function which is polymorphic over a universally-quantified type 'a. This function is passed a unit -> 'a function, which must be immediately executed, and the result of which must be returned.
The function passed to the instrumentor will be doing the bulk of the work for the Incr_map function in question (usually a Map.fold_symmetric_diff).
You may want to use the Instrumentation API to assist in performance profiling like so:
let profile name =
{ Incr_map.Instrumentation.f = fun f ->
let before = Time.now () in
let r = f () in
let after = Time.now () in
let delta = Time.sub after before in
printf "%s took %s" name (Time.Span.to_string_hum delta);
r
}
;;
Incr_map.map ~instrumentation:(profile "foo") ~f:map_foo