From c14f0b4ac80fc33c2b8bf869a41e612ddccda15d Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sat, 11 Dec 2021 16:59:48 -0800 Subject: [PATCH] perf_hooks: multiple fixes for Histogram * The createHistogram(options) options weren't actually implemented * Add a new count property that tracks the number of samples * Adds BigInt options for relevant properties * Adds add(other) method for RecordableHistogram * Cleans up and expands tests * Eliminates unnecessary ELDHistogram native class * Improve/Simplify histogram transfer impl Signed-off-by: James M Snell perf_hooks: simplify Histogram constructor options Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/41153 Reviewed-By: Matteo Collina --- doc/api/perf_hooks.md | 89 ++++++- lib/internal/histogram.js | 259 ++++++++++++++++--- lib/internal/perf/event_loop_delay.js | 41 ++- src/histogram-inl.h | 49 ++-- src/histogram.cc | 280 +++++++++++++++++++-- src/histogram.h | 83 +++--- src/node_perf.cc | 67 ++--- src/node_perf.h | 17 -- test/parallel/test-perf-hooks-histogram.js | 133 +++++++--- 9 files changed, 807 insertions(+), 211 deletions(-) diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index e61710d1ec96fd..a35cef0f02da22 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -815,10 +815,11 @@ added: v15.9.0 --> * `options` {Object} - * `min` {number|bigint} The minimum recordable value. Must be an integer + * `lowest` {number|bigint} The lowest discernible value. Must be an integer value greater than 0. **Default:** `1`. - * `max` {number|bigint} The maximum recordable value. Must be an integer - value greater than `min`. **Default:** `Number.MAX_SAFE_INTEGER`. + * `highest` {number|bigint} The highest recordable value. Must be an integer + value that is equal to or greater than two times `min`. + **Default:** `Number.MAX_SAFE_INTEGER`. * `figures` {number} The number of accuracy digits. Must be a number between `1` and `5`. **Default:** `3`. * Returns {RecordableHistogram} @@ -868,6 +869,26 @@ console.log(h.percentile(99)); added: v11.10.0 --> +### `histogram.count` + + + +* {number} + +The number of samples recorded by the histogram. + +### `histogram.countBigInt` + + + +* {bigint} + +The number of samples recorded by the histogram. + ### `histogram.exceeds` + +* {bigint} + +The number of times the event loop delay exceeded the maximum 1 hour event +loop delay threshold. + ### `histogram.max` + +* {bigint} + +The maximum recorded event loop delay. + ### `histogram.mean` + +* {bigint} + +The minimum recorded event loop delay. + ### `histogram.percentile(percentile)` + +* `percentile` {number} A percentile value in the range (0, 100). +* Returns: {bigint} + +Returns the value at the given percentile. + ### `histogram.percentiles` + +* {Map} + +Returns a `Map` object detailing the accumulated percentile distribution. + ### `histogram.reset()` +### `histogram.add(other)` + + + +* `other` {RecordableHistogram} + +Adds the values from `other` to this histogram. + ### `histogram.record(val)`