Mavryk_base.Profiler
This profiling library declares a high-level interface meant to be used to instrument code in order to measure the time spent in the different parts in such a way to yield a (human-)processable report. This module declares a generic interface (driver) that will provide an API to the developer to instrument the code. When the profiling data is recorded, the abstracted profiler will feed it to its "plugged" backend (instance) which will process the different profiler's nodes in order to produce the reports. Reports may also be combined to interwine different components' traces.
The provided API is intentionally simplistic to simplify its usage. The basic usage is to call record <symbol>
before the desired section to profile and stop ()
when we exit it. Nested calls are also supported and, given that the backend supports it, will be displayed as a callgraph. The API is also augmented with higher-level combinators in order to avoid mismatched stop
s and to support Lwt
function calls.
module StringMap : Mavryk_error_monad.TzLwtreslib.Map.S with type key = string
val zero_time : span
The level of detail of report sections. The driver can choose to use this information to skip or aggregate sections below a given level. The driver could also record everything, including the level of detail, and let a post processor skip or aggregate at display time.
type aggregated_node = {
count : int;
total : span;
children : aggregated_node StringMap.t;
node_lod : lod;
}
An aggregate node registers multiple calls to a section and sum their occurences and time. It also recursively aggregate its sub-aggregation nodes.
A sequence item registers one section with potential sub-reports and registers elapsed-time.
val report_encoding : report Data_encoding.t
module type DRIVER = sig ... end
val close : instance -> unit
val close_and_unplug_all : profiler -> unit
val stop : profiler -> unit
val unplugged : unit -> profiler
val main : profiler
module type GLOBAL_PROFILER = sig ... end
val wrap : profiler -> (module GLOBAL_PROFILER)