package ecaml

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

Module Nested_profile.ProfileSource

This is a library for time profiling sequential or Async code.

Wrap interesting places in your code with calls to profile:

  open! Nested_profile;;

  profile "do_thing" (fun () ->
    profile "foo" foo;
    profile "bar" bar;
    ...)

Then each top-level call to profile will output a hierarchical display of all profile calls beneath it:

  1.284s -- do_thing
    209.266ms -- foo
    1.074s -- bar
Sourcemodule Sync_or_async : sig ... end

A Sync_or_async.t specifies whether the computation being profiled is synchronous or asynchronous.

Sourceval profile : ?hide_if_less_than:Core.Time_ns.Span.t -> 'a Sync_or_async.t -> Core.Sexp.t Core.Lazy.t -> (unit -> 'a) -> 'a

profile sync_or_async message f measures the time taken to run f, and outputs the result. Nested calls to profile are displayed as a tree. Use Async to profile Async code. It is safe to nest calls to profile inside calls to profile Async. profile Async does have some restrictions in order to get valid results:

  • a nested call to profile Async must exit before its parent does
  • there cannot be multiple sibling calls to profile Async running concurrently
Sourceval am_forcing_message : unit -> bool

am_forcing_message () returns true when profiling is calling force on a message supplied to profile. This is useful if you want to have a sexp_of_t function behave differently when producing messages.

Sourceval approximate_line_length_limit : int Core.ref
Sourceval should_profile : bool Core.ref
Sourceval hide_if_less_than : Core.Time_ns.Span.t Core.ref
Sourceval hide_top_level_if_less_than : Core.Time_ns.Span.t Core.ref
Sourceval never_show_rendering_took : bool Core.ref
Sourceval sexp_of_time_ns : (Core.Time_ns.t -> Core.Sexp.t) Core.ref
Sourceval tag_frames_with : (unit -> Core.Sexp.t option) option Core.ref
Sourceval output_profile : (string -> unit) Core.ref

profile calls output_profile to display the profile to the user. It is print_string by default.

Sourcemodule Start_location : sig ... end
Sourceval start_location : Start_location.t Core.ref

start_location specifies where in a profile the start time is rendered.

Sourceval backtrace : unit -> Core.Sexp.t list option

Return the current stack of profile messages, sorted inner profile frames first. Returns None if should_profile is false.

Sourceval disown : (unit -> 'a) -> 'a

disown f runs f as though it were at top level, rather than whatever the current context is. In other words, it causes the parent (current) context to disown children created by f. This is useful for background jobs that might outlive their parents, since Nested_profile requires that parents wait for their children.

Sourcemodule Private : sig ... end
OCaml

Innovation. Community. Security.