HdrHistogram.js is a TypeScript port of the HdrHistogram library, designed for high-fidelity recording and analysis of latency and other value distributions in both Node.js and web browser environments. The library is currently stable at version 3.0.1, with a history of regular updates including significant architectural changes. A key differentiator since version 2 is the introduction of an optional WebAssembly (WASM) implementation, leveraging AssemblyScript to provide substantial performance gains for recording and processing histograms, though this is not enabled by default. It supports core HdrHistogram features such as regular and coordinated omission-corrected latency recording, resizable and memory-optimized 'packed' histograms, and the ability to add, subtract, encode, and decode compressed histograms. It also includes client-side data visualization tools for browser-based analysis. Release cadence appears to be driven by feature enhancements and performance optimizations, with major versions often introducing substantial improvements.
npm install hdr-histogram-jsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to build a histogram, record values, and retrieve basic percentile metrics, including an example of coordinated omission correction.
Review the WebAssembly section in the documentation (since hdrhistogramjs v2) to understand performance implications and how to opt-in to WASM. The `useWebAssembly` option on `build()` is `false` by default.
When building a histogram, set `useWebAssembly: true` in the options object passed to `hdr.build()`. Ensure your execution environment supports WebAssembly.
Carefully evaluate your use case. For high-performance, higher-throughput scenarios, avoid `bitBucketSize: 'packed'`. For minimal memory usage with infrequent updates, 'packed' may be suitable. The default `bitBucketSize` is usually a good balance.
Ensure your Node.js environment is version 14 or higher to guarantee compatibility and access to modern JavaScript features and WebAssembly support.
Convert `require('hdr-histogram-js')` to `import * as hdr from 'hdr-histogram-js'` or `import { build } from 'hdr-histogram-js'`.Use named import syntax: `import { build } from 'hdr-histogram-js'`.Either remove `useWebAssembly: true` to fall back to the TypeScript implementation, or ensure the execution environment fully supports WebAssembly (e.g., update browser, use a compatible Node.js version).
No dependency data recorded yet.