M
perf_hooks.importHistogram
History
Added in: v26.9.0
v26.9.0
Introduced in: v8.5.0
v8.5.0
Format version 2 is supported. Unknown keys in version 2 data are ignored.
v26.11.0
perf_hooks.importHistogram(data): RecordableHistogram
Attributes
data:
Uint8ArrayA CBOR-encoded histogram previously produced by
histogram.export().Returns:
RecordableHistogramReconstructs a histogram from a CBOR-encoded Uint8Array. The returned
histogram is a full RecordableHistogram with all bucket data, configuration,
and EWMA state restored. New values can be recorded into it.
Data in any format version produced by histogram.export() can be
imported. See histogram export format compatibility for details.
const { createHistogram, importHistogram } = require('node:perf_hooks'); const h = createHistogram(); for (let i = 1; i <= 1000; i++) h.record(i); // Serialize and reconstruct const data = h.export(); const h2 = importHistogram(data); console.log(h2.count); // 1000 console.log(h2.percentile(99)); // Same as h.percentile(99)