Analysis functions for allocation trace data.
Provides functions for summarizing allocations, detecting hotspots, and grouping by object type. Functions follow the pipeline pattern where each takes options and returns a transformer function that operates on a data-map.
Analysis functions for allocation trace data. Provides functions for summarizing allocations, detecting hotspots, and grouping by object type. Functions follow the pipeline pattern where each takes options and returns a transformer function that operates on a data-map.
(->allocation-analyse analyse-plan)Creates a composite analysis function from a sequence of analysis specs.
Each spec is either a keyword/symbol to resolve a function, or a vector with a keyword/symbol first element followed by an options map.
Analysis functions are resolved from the criterium.allocation.analysis namespace. They are composed in sequence, each taking and returning a data-map.
Example specs: [[:summary-fn {:id :summary}] [:hotspots-fn {:limit 5}] [:by-type-fn {}]]
Returns a function that takes a data-map and returns the analyzed data-map.
Creates a composite analysis function from a sequence of analysis specs.
Each spec is either a keyword/symbol to resolve a function, or a vector
with a keyword/symbol first element followed by an options map.
Analysis functions are resolved from the criterium.allocation.analysis
namespace. They are composed in sequence, each taking and returning a
data-map.
Example specs:
[[:summary-fn {:id :summary}]
[:hotspots-fn {:limit 5}]
[:by-type-fn {}]]
Returns a function that takes a data-map and returns the analyzed data-map.(by-type-fn)(by-type-fn {:keys [id trace-id]})Returns a function that groups allocations by object type.
Parameters: opts - Map with keys: :id - Key for result in output (default: :allocation-by-type) :trace-id - Path for source allocation trace (default: [:samples :allocation-trace])
The returned function:
Result contains: :type - :criterium/allocation-by-type :by-type - Map of object-type to stats: {"Ljava/lang/String;" {:count N :bytes M :freed-count K :freed-bytes L} ...}
Returns a function that groups allocations by object type.
Parameters:
opts - Map with keys:
:id - Key for result in output (default: :allocation-by-type)
:trace-id - Path for source allocation trace
(default: [:samples :allocation-trace])
The returned function:
- Takes a data-map containing an allocation trace at :trace-id path
- Returns the data-map with by-type grouping added under :id
- Returns data-map unchanged if trace is not present (no-op)
Result contains:
:type - :criterium/allocation-by-type
:by-type - Map of object-type to stats:
{"Ljava/lang/String;" {:count N
:bytes M
:freed-count K
:freed-bytes L} ...}(hotspots-fn)(hotspots-fn {:keys [id trace-id limit order-by]})Returns a function that identifies allocation hotspots.
Identified by call-site and object type.
Parameters: opts - Map with keys: :id - Key for result in output (default: :allocation-hotspots) :trace-id - Path for source allocation trace (default: [:samples :allocation-trace]) :limit - Maximum number of hotspots to return (default: 10) :order-by - Sort key, :bytes or :count (default: :bytes)
The returned function:
Hotspots result contains: :type - :criterium/allocation-hotspots :hotspots - Vector of maps sorted by bytes descending: [{:call-site {:call-class ... :call-method ... :call-file ... :call-line ...} :object-type "Ljava/lang/String;" :count N :bytes M :freed-count K :freed-bytes L} ...]
Note: When call-* fields are empty, alloc-* fields are used as fallback.
Returns a function that identifies allocation hotspots.
Identified by call-site and object type.
Parameters:
opts - Map with keys:
:id - Key for result in output (default: :allocation-hotspots)
:trace-id - Path for source allocation trace
(default: [:samples :allocation-trace])
:limit - Maximum number of hotspots to return (default: 10)
:order-by - Sort key, :bytes or :count (default: :bytes)
The returned function:
- Takes a data-map containing an allocation trace at :trace-id path
- Returns the data-map with hotspots added under :id
- Returns data-map unchanged if trace is not present (no-op)
Hotspots result contains:
:type - :criterium/allocation-hotspots
:hotspots - Vector of maps sorted by bytes descending:
[{:call-site {:call-class ...
:call-method ...
:call-file ...
:call-line ...}
:object-type "Ljava/lang/String;"
:count N
:bytes M
:freed-count K
:freed-bytes L} ...]
Note: When call-* fields are empty, alloc-* fields are used as fallback.(summary-fn)(summary-fn {:keys [id trace-id]})Returns a function that computes allocation summary statistics.
Parameters: opts - Map with keys: :id - Key for result in output (default: :allocation-summary)
:trace-id - Path for source allocation trace
(default: [:samples :allocation-trace])
The returned function:
Summary contains: :type - :criterium/allocation-summary :total-allocated - Total bytes allocated :total-freed - Total bytes from freed objects :num-allocations - Total number of allocations :num-freed - Number of allocations that were freed :freed-ratio - Ratio of bytes freed to bytes allocated (0.0 to 1.0)
Returns a function that computes allocation summary statistics.
Parameters:
opts - Map with keys:
:id - Key for result in output (default: :allocation-summary)
:trace-id - Path for source allocation trace
(default: [:samples :allocation-trace])
The returned function:
- Takes a data-map containing an allocation trace at :trace-id path
- Returns the data-map with summary added under :id
- Returns data-map unchanged if trace is not present (no-op)
Summary contains:
:type - :criterium/allocation-summary
:total-allocated - Total bytes allocated
:total-freed - Total bytes from freed objects
:num-allocations - Total number of allocations
:num-freed - Number of allocations that were freed
:freed-ratio - Ratio of bytes freed to bytes allocated (0.0 to 1.0)(treemap-fn)(treemap-fn {:keys [id trace-id group-by size-by filter-by]})Returns a function that transforms allocation records into treemap data.
Parameters: opts - Map with keys: :id - Key for result in output (default: :allocation-treemap) :trace-id - Path for source allocation trace (default: [:samples :allocation-trace]) :group-by - Hierarchy option: :class→line→type (default): calling-class → calling-line → object-type :type→class→line: object-type → calling-class → calling-line :size-by - Value for node sizing: :count, :bytes, :bytes-per-allocation (default: :bytes) :filter-by - Filter records: :freed, :not-freed, :all (default: :all)
The returned function:
Treemap result contains: :type - :criterium/allocation-treemap :group-by - The grouping option used :size-by - The sizing option used :root - Root node with :name, :value, and optional :children Leaf nodes have no :children key Values at each level are sum of children values
Returns a function that transforms allocation records into treemap data.
Parameters:
opts - Map with keys:
:id - Key for result in output (default: :allocation-treemap)
:trace-id - Path for source allocation trace
(default: [:samples :allocation-trace])
:group-by - Hierarchy option:
:class→line→type (default):
calling-class → calling-line → object-type
:type→class→line:
object-type → calling-class → calling-line
:size-by - Value for node sizing: :count, :bytes, :bytes-per-allocation
(default: :bytes)
:filter-by - Filter records: :freed, :not-freed, :all (default: :all)
The returned function:
- Takes a data-map containing an allocation trace at :trace-id path
- Returns the data-map with treemap added under :id
- Returns data-map unchanged if trace is not present (no-op)
Treemap result contains:
:type - :criterium/allocation-treemap
:group-by - The grouping option used
:size-by - The sizing option used
:root - Root node with :name, :value, and optional :children
Leaf nodes have no :children key
Values at each level are sum of children valuescljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |