Performance

createHistogram()

Creates a recordable histogram for positive integer observations. Choose one unit, such as microseconds, and use it consistently. Percentiles summarize a distribution rather than identifying an individual request. Tested on Node.js 22.16.0. Example output (one line per entry): ["3 10 30", "0"].

Formal Syntax & Structure

nodejs syntaxnodejs
createHistogram([options])

Parameters & Attributes

NameTypeDescription
optionsobjectRange and precision options.

Return Value

RecordableHistogram

Histogram for recorded values.

Working Example

Example Snippetnodejs
import { createHistogram } from 'node:perf_hooks';const h = createHistogram();for (const n of [10, 20, 30])    h.record(n);console.log(h.count, h.min, h.max);h.reset();console.log(h.count);
Node.js Reference