Liking cljdoc? Tell your friends :D

criterium.analyse.call-graph

Analysis functions for call graph data from method tracing.

Provides analysis functions that operate on call tree data collected via the method tracing agent.

Analysis functions for call graph data from method tracing.

Provides analysis functions that operate on call tree data collected
via the method tracing agent.
raw docstring

filter-callsclj

(filter-calls)
(filter-calls {:keys [id call-tree-id exclude-packages stop-at-packages
                      max-depth]
               :or {id :filtered call-tree-id :call-tree}})

Analysis function that filters the call graph and stores the result.

Applies filter-call-tree to the source call tree and stores the filtered result under a new identifier. Multiple filter-calls can be chained to create different filtered views of the same call tree.

Parameters: opts - Optional map with keys: :id - Key for result in output (default: :filtered) :call-tree-id - Key for source call tree (default: :call-tree) :exclude-packages - Set of package prefixes to exclude entirely. Nodes with matching classes are removed, their children promoted up. :stop-at-packages - Set of package prefixes where traversal stops. Matching nodes are kept but their children are truncated. :max-depth - Maximum depth to include (1 = root only, 2 = root + children, etc.)

The returned function:

  • Takes a data-map containing :call-tree (or custom :call-tree-id)
  • Returns the data-map with filtered tree added under :id key
  • Returns data-map unchanged if call-tree is not present

Result structure: {:type :criterium/filtered-call-tree :source-id :call-tree :filter-opts {...} :call-tree <filtered-tree>}

Example: ;; In call-graph-plan :analyse [[:filter-calls {:id :filtered :exclude-packages #{"java." "sun."} :stop-at-packages #{"clojure.core"}}]]

;; Result structure {:call-tree original-tree :filtered {:type :criterium/filtered-call-tree :source-id :call-tree :filter-opts {...} :call-tree filtered-tree}}

Analysis function that filters the call graph and stores the result.

Applies filter-call-tree to the source call tree and stores the filtered
result under a new identifier. Multiple filter-calls can be chained to
create different filtered views of the same call tree.

Parameters:
  opts - Optional map with keys:
    :id               - Key for result in output (default: :filtered)
    :call-tree-id     - Key for source call tree (default: :call-tree)
    :exclude-packages - Set of package prefixes to exclude entirely.
                        Nodes with matching classes are removed,
                        their children promoted up.
    :stop-at-packages - Set of package prefixes where traversal stops.
                        Matching nodes are kept but their children
                        are truncated.
    :max-depth        - Maximum depth to include (1 = root only,
                        2 = root + children, etc.)

The returned function:
- Takes a data-map containing :call-tree (or custom :call-tree-id)
- Returns the data-map with filtered tree added under :id key
- Returns data-map unchanged if call-tree is not present

Result structure:
{:type :criterium/filtered-call-tree
 :source-id :call-tree
 :filter-opts {...}
 :call-tree <filtered-tree>}

Example:
;; In call-graph-plan :analyse
[[:filter-calls {:id :filtered
                 :exclude-packages #{"java." "sun."}
                 :stop-at-packages #{"clojure.core"}}]]

;; Result structure
{:call-tree original-tree
 :filtered {:type :criterium/filtered-call-tree
            :source-id :call-tree
            :filter-opts {...}
            :call-tree filtered-tree}}
sourceraw docstring

most-calledclj

(most-called)
(most-called {:keys [id call-tree-id limit]
              :or {id :most-called call-tree-id :call-tree limit 20}})

Analysis function that identifies the most frequently called methods.

Flattens the call tree and aggregates by class+method, returning a sorted vector of the top N methods by total call count.

Parameters: opts - Optional map with keys: :id - Key for result in output (default: :most-called) :call-tree-id - Key for source call tree (default: :call-tree) :limit - Maximum methods to return (default: 20)

The returned function:

  • Takes a data-map containing :call-tree
  • Returns the data-map with :most-called added
  • Returns data-map unchanged if call-tree is not present

Result structure: {:type :criterium/most-called :most-called [{:class "com.example.Foo" :method "bar" :file "Foo.java" :line 42 :total-calls 1500} ...]}

Example: (let [analyze (most-called {:limit 10}) result (analyze {:call-tree {...}})] (:most-called result))

Analysis function that identifies the most frequently called methods.

Flattens the call tree and aggregates by class+method, returning a sorted
vector of the top N methods by total call count.

Parameters:
  opts - Optional map with keys:
    :id           - Key for result in output (default: :most-called)
    :call-tree-id - Key for source call tree (default: :call-tree)
    :limit        - Maximum methods to return (default: 20)

The returned function:
- Takes a data-map containing :call-tree
- Returns the data-map with :most-called added
- Returns data-map unchanged if call-tree is not present

Result structure:
{:type :criterium/most-called
 :most-called [{:class "com.example.Foo"
                :method "bar"
                :file "Foo.java"
                :line 42
                :total-calls 1500}
               ...]}

Example:
(let [analyze (most-called {:limit 10})
      result (analyze {:call-tree {...}})]
  (:most-called result))
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close