package octez-libs

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Tezos_base.ProfilerSource

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 stops and to support Lwt function calls.

Sourcetype time = {
  1. wall : float;
    (*

    Wall-clock time: total time elapsed.

    *)
  2. cpu : float;
    (*

    CPU time: time elapsed in the CPU.

    *)
}
Sourcetype span =
  1. | Span of time
Sourceval zero_time : span
Sourceval (-*) : time -> time -> time
Sourceval (+*) : time -> time -> time
Sourcetype lod =
  1. | Terse
  2. | Detailed
  3. | Verbose

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.

Sourcetype aggregated_node = {
  1. count : int;
  2. total : span;
  3. children : aggregated_node StringMap.t;
  4. 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.

Sourcetype seq_item = {
  1. start : time;
  2. duration : span;
  3. contents : report;
  4. item_lod : lod;
}

A sequence item registers one section with potential sub-reports and registers elapsed-time.

Sourceand report = {
  1. aggregated : aggregated_node StringMap.t;
  2. recorded : (string * seq_item) list;
}
Sourceval report_encoding : report Data_encoding.t
Sourcetype (_, _) kind = ..
Sourcemodule type DRIVER = sig ... end
Sourcetype 'a driver = (module DRIVER with type config = 'a)
Sourcetype instance
Sourceval instance : 'a driver -> 'a -> instance
Sourceval time : instance -> time
Sourceval report : instance -> report option
Sourceval report_s : instance -> report Lwt.t
Sourceval close : instance -> unit
Sourcetype profiler
Sourceval plug : profiler -> instance -> unit
Sourceval unplug : profiler -> instance -> unit
Sourceval close_and_unplug : profiler -> instance -> unit
Sourceval close_and_unplug_all : profiler -> unit
Sourceval plugged : profiler -> instance list
Sourceval record : profiler -> ?lod:lod -> string -> unit
Sourceval aggregate : profiler -> ?lod:lod -> string -> unit
Sourceval stop : profiler -> unit
Sourceval stamp : profiler -> ?lod:lod -> string -> unit
Sourceval mark : profiler -> ?lod:lod -> string list -> unit
Sourceval span : profiler -> ?lod:lod -> span -> string list -> unit
Sourceval inc : profiler -> report -> unit
Sourceval record_f : profiler -> ?lod:lod -> string -> (unit -> 'a) -> 'a
Sourceval record_s : profiler -> ?lod:lod -> string -> (unit -> 'a Lwt.t) -> 'a Lwt.t
Sourceval aggregate_f : profiler -> ?lod:lod -> string -> (unit -> 'a) -> 'a
Sourceval aggregate_s : profiler -> ?lod:lod -> string -> (unit -> 'a Lwt.t) -> 'a Lwt.t
Sourceval span_f : profiler -> ?lod:lod -> string list -> (unit -> 'a) -> 'a
Sourceval span_s : profiler -> ?lod:lod -> string list -> (unit -> 'a Lwt.t) -> 'a Lwt.t
Sourceval with_new_profiler : 'a driver -> 'a -> (profiler -> 'r) -> 'r * report list
Sourceval with_new_profiler_s : 'a driver -> 'a -> (profiler -> 'r Lwt.t) -> ('r * report list) Lwt.t
Sourceval unplugged : unit -> profiler
Sourceval main : profiler
Sourcemodule type GLOBAL_PROFILER = sig ... end
Sourceval wrap : profiler -> (module GLOBAL_PROFILER)
OCaml

Innovation. Community. Security.