package landmarks

  1. Overview
  2. Docs

The main module

val clock : unit -> Int64.t

This function is used by the landmark infrastructure to measure the number of cycles inside landmarks.

exception LandmarkFailure of string

Landmarks

Landmarks identify portions of code, they are registered with the function register and delimited by enter and exit.

type landmark

The type of landmarks.

val register : ?location:string -> string -> landmark

register name registers a new landmark. Should always be called at top-level.

val enter : landmark -> unit

Begins a landmark block. /!\ Landmark blocks should be well-nested, otherwise a failure will be raised during profiling.

val exit : landmark -> unit

Ends a landmark block.

val wrap : landmark -> ('a -> 'b) -> 'a -> 'b

Puts landmark blocks around a function (and close the block and re-raise in case of uncaught exception).

val unsafe_wrap : landmark -> ('a -> 'b) -> 'a -> 'b

Puts landmark blocks around a function without catching exceptions.

Counter and samplers

Counters are similar to landmarks except they represent empty pieces of code. Their only primitive is increment which adds a constant to the field calls. Samplers are used to collect floats.

type counter

The type of counters.

val register_counter : string -> counter

register_counter name registers a new counter. Should always be called at top-level.

val increment : ?times:int -> counter -> unit

Increments the number of calls attached to the counter.

type sampler

The type of samplers.

val register_sampler : string -> sampler

register_counter name registers a new sampler.

val sample : sampler -> float -> unit

Collects a float.

Manage profiling

val profiling : unit -> bool

Checks if the profiling is ongoing.

type profile_output =
  1. | Silent
    (*

    disables the automatic output of profiling results when the program ends.

    *)
  2. | Temporary of string option
    (*

    writes the results in a temporary files and prints its path on stderr.

    *)
  3. | Channel of out_channel
    (*

    writes in the results in out_channel.

    *)

Where to output results.

type profile_format =
  1. | JSON
    (*

    Easily parsable export format.

    *)
  2. | Textual
    (*

    Console friendly output.

    *)

The output format for the results.

type profiling_options = {
  1. debug : bool;
    (*

    Activates a verbose mode that outputs traces on stderr each time the landmarks primitives are called. Default: false.

    *)
  2. allocated_bytes : bool;
    (*

    Also collect Gc.allocated_bytes during profiling.

    *)
  3. sys_time : bool;
    (*

    Also collect Sys.time timestamps during profiling.

    *)
  4. recursive : bool;
    (*

    When false, the recursive instances of landmarks (entering a landmark that has already been entered) are ignored (the number of calls is updated but it does not generate a new node in the callgraph).

    *)
  5. output : profile_output;
    (*

    Specify where to output the results.

    *)
  6. format : profile_format;
    (*

    Specify the output format.

    *)
}

The profiling options control the behavior of the landmark infrastructure.

val default_options : profiling_options

The default profiling_options.

val set_profiling_options : profiling_options -> unit

Sets the options.

val profiling_options : unit -> profiling_options

Get the options.

val start_profiling : ?profiling_options:profiling_options -> unit -> unit

Starts the profiling.

val stop_profiling : unit -> unit

Stops the profiling.

val reset : unit -> unit

Reset the profiling information gathered by the current process.

val export : ?label:string -> unit -> Landmark_graph.graph

Export the profiling information of the current process.

val export_and_reset : ?label:string -> unit -> Landmark_graph.graph

Export the profiling information of the current process; then reset internal state.

val merge : Landmark_graph.graph -> unit

Aggregate the profiling information (exported by another process) to the current one. This should is used by the master process to merge exported profiles of slaves.

OCaml

Innovation. Community. Security.