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.
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)