A Node.js native addon for HdrHistogram using N-API.
This module is in active development and is not yet ready for production use.
This module, which is implemented using N-API, is meant to be an API-compatable alternative to the native-hdr-histogram module which is implemented using NAN. Both modules implement Node.js native addons that wrap the HdrHistogram_c library.
The majority of the files in this module are generated by an automated tool that parses the source C files and generates the binding files. The objective is to create a very light-weight wrapper to the native C functions and then augment these native classes with JavaScript as necessary.
In this module, HdrHistogram and HdrHistogramIterator are native classes implemented using N-API. The JavaScript Histogram class extends the native HdrHistogram class and implements the additional methods necessary to achieve compatibility with the native-hdr-histogram Histogram class.
This table shows the existing Histogram methods available in the native-hdr-histogram module (NAN) and the corresponding and additional methods available in this module (N-API).
| NAN | HdrHistogram_c Function | N-API |
|---|---|---|
| record | hdr_record_value | record |
| min | hdr_min | min |
| max | hdr_max | max |
| mean | hdr_mean | mean |
| stddev | hdr_stddev | stddev |
| percentile | hdr_value_at_percentile | percentile |
| encode | hdr_log_encode | encode ‡ |
| decode † | hdr_log_decode | decode †‡ |
| percentiles | hdr_iter_percentile_init hdr_iter_next | percentiles ‡ |
| reset | hdr_reset | reset |
| hdr_reset_internal_counters | resetInternalCounters | |
| hdr_get_memory_size | getMemorySize | |
| hdr_record_value_atomic | recordAtomic | |
| hdr_record_values | recordValues | |
| hdr_record_values_atomic | recordValuesAtomic | |
| hdr_record_corrected_value | recordCorrectedValue | |
| hdr_record_corrected_value_atomic | recordCorrectedValueAtomic | |
| hdr_record_corrected_values | recordCorrectedValues | |
| hdr_record_corrected_values_atomic | recordCorrectedValuesAtomic | |
| hdr_add | add | |
| hdr_values_are_equivalent | valuesAreEquivalent | |
| hdr_lowest_equivalent_value | lowestEquivalentValue | |
| hdr_count_at_value | countAtValue | |
| hdr_log_encode | getEncoded | |
| hdr_log_decode | setEncoded |
† This is a static method.
‡ Implemented in JavaScript using the native N-API classes and accessor methods.
The immediate plan is to continue enhancing this module until it's ready for production use. These steps are:
- Modify the
Histogramconstructor so that it is completely compatible with the native-hdr-histogram version. - Complete detailed verification on the code.
- Generate configuration information to support
prebuildfor creating and uploading native binaries. - Build out unit tests.
- Implement GitHub CI to
prebuildfor various architectures. - Generate complete documentation.
- Publish to
npm.