package landmarks

  1. Overview
  2. Docs

Module Landmark.GraphSource

All about exporting profiling results

A callgraph is a tree where each node is an instance of a Landmark.landmark representing the entering and exiting of instrumented code in the execution path.

Sourcetype id = int

Identifies nodes

Sourcetype kind =
  1. | Normal
    (*

    Usual landmarks

    *)
  2. | Root
    (*

    The special node that started with the profiling.

    *)
  3. | Counter
    (*

    Counters (see Landmark.counter)

    *)
  4. | Sampler
    (*

    Samplers (set Landmark.sampler)

    *)

The kind of node.

Sourcetype node = {
  1. id : id;
    (*

    Unique identifier.

    *)
  2. kind : kind;
  3. landmark_id : string;
    (*

    The node is an instance of this landmark.

    *)
  4. name : string;
    (*

    Name of the landmark (see Landmark.register).

    *)
  5. location : string;
    (*

    Location of the landmark (see Landmark.register).

    *)
  6. calls : int;
    (*

    Number of time this node was entered.

    *)
  7. time : float;
    (*

    Time (in cycles) spent between enter and exit.

    *)
  8. children : id list;
    (*

    The list of instances of landmarks that was entered while the node was opened.

    *)
  9. sys_time : float;
    (*

    Time (using Sys.time) spent between enter and exit.

    *)
  10. allocated_bytes : float;
    (*

    Gc.allocated_bytes between enter and exit.

    *)
  11. distrib : floatarray;
    (*

    For samplers only. The list of collected samples.

    *)
}

The type exported view of a node.

Callgraph

Sourcetype graph = {
  1. nodes : node array;
  2. label : string;
  3. root : id;
}

The type of callgraphs.

Sourceval nodes : graph -> node list

Returns all nodes of a graph.

Sourceval root : graph -> node

Returns the root of a graph.

Sourceval children : graph -> node -> node list

Returns the children of node(children graph node is equivalent to List.map (node_of_id graph) node.children

Sourceval subgraph : graph -> node -> graph

Change the root of a graph

Sourceval label : graph -> node -> string

Returns a fully qualified name if it is needed.

Sourceval graph_of_nodes : ?label:string -> ?root:id -> node list -> graph

Build a graph from a list of nodes.

Traversal

Sourceval path_dfs : (bool -> node list -> node -> unit) -> (node list -> node -> unit) -> graph -> unit

path_dfs f g graph traverses the graph in the depth-first fashion starting from the root. At each step we call f visited path v or g path v where v is the visited node and path is the path from the root that led us to that node. The function g is called when the visited node v belongs to path; it indicates a loop (and the traversal does not continue with the children of g). The function f is called when v does not belong to path. The flag visited is true when the vertex has already been visited.

Sourceval dfs : (node list -> node -> bool) -> (node list -> node -> unit) -> graph -> unit

A specialization of path_dfs that does not need to read the visited flag. The returned values of the first function tells whether or not the traversal should continue visiting the children of the current node.

Utility functions

Sourceval depth : graph -> node -> int

Returns the depth to the root of the node (it is better to partially apply the function, if you need to call multiple times on the same graph).

Sourceval shallow_ancestor : graph -> node -> node

Returns the oldest ancestor of a node that is not the root (if it exists) or the root if it does not exist.

Sourceval intensity : ?proj:(node -> float) -> graph -> node -> float

Returns an arbitrary number between 0.0 and 1.0.

Sourceval total_number_of_calls : graph -> int

Compute the sum of all calls field.

Simplification / Merge / Quotienting.

Sourceval prune : graph -> graph

Remove the unaccessible nodes from a graph.

Sourceval aggregate_landmarks : graph -> graph

aggregate_landmarks g computes the quotient by the relation "being an instance of the same landmark".

Output

Sourceval output : ?threshold:float -> out_channel -> graph -> unit

Pretty printed output a call graph on an out_channel.

Sourceval output_json : out_channel -> graph -> unit

Output a JSON representation of a call graph on an out_channel.

OCaml

Innovation. Community. Security.