Skip to content

Commit

Permalink
perf_hooks: multiple fixes for Histogram
Browse files Browse the repository at this point in the history
* 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 <jasnell@gmail.com>

perf_hooks: simplify Histogram constructor options

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: #41153
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
jasnell committed Dec 19, 2021
1 parent 665b404 commit 23637e9
Show file tree
Hide file tree
Showing 9 changed files with 807 additions and 211 deletions.
89 changes: 86 additions & 3 deletions doc/api/perf_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,11 @@ added:
-->

* `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}
Expand Down Expand Up @@ -870,6 +871,26 @@ console.log(h.percentile(99));
added: v11.10.0
-->

### `histogram.count`

<!-- YAML
added: REPLACEME
-->

* {number}

The number of samples recorded by the histogram.

### `histogram.countBigInt`

<!-- YAML
added: REPLACEME
-->

* {bigint}

The number of samples recorded by the histogram.

### `histogram.exceeds`

<!-- YAML
Expand All @@ -881,6 +902,17 @@ added: v11.10.0
The number of times the event loop delay exceeded the maximum 1 hour event
loop delay threshold.

### `histogram.exceedsBigInt`

<!-- YAML
added: REPLACEME
-->

* {bigint}

The number of times the event loop delay exceeded the maximum 1 hour event
loop delay threshold.

### `histogram.max`

<!-- YAML
Expand All @@ -891,6 +923,16 @@ added: v11.10.0

The maximum recorded event loop delay.

### `histogram.maxBigInt`

<!-- YAML
added: REPLACEME
-->

* {bigint}

The maximum recorded event loop delay.

### `histogram.mean`

<!-- YAML
Expand All @@ -911,6 +953,16 @@ added: v11.10.0

The minimum recorded event loop delay.

### `histogram.minBigInt`

<!-- YAML
added: REPLACEME
-->

* {bigint}

The minimum recorded event loop delay.

### `histogram.percentile(percentile)`

<!-- YAML
Expand All @@ -922,6 +974,17 @@ added: v11.10.0

Returns the value at the given percentile.

### `histogram.percentileBigInt(percentile)`

<!-- YAML
added: REPLACEME
-->

* `percentile` {number} A percentile value in the range (0, 100).
* Returns: {bigint}

Returns the value at the given percentile.

### `histogram.percentiles`

<!-- YAML
Expand All @@ -932,6 +995,16 @@ added: v11.10.0

Returns a `Map` object detailing the accumulated percentile distribution.

### `histogram.percentilesBigInt`

<!-- YAML
added: REPLACEME
-->

* {Map}

Returns a `Map` object detailing the accumulated percentile distribution.

### `histogram.reset()`

<!-- YAML
Expand Down Expand Up @@ -990,6 +1063,16 @@ added:
- v14.18.0
-->

### `histogram.add(other)`

<!-- YAML
added: REPLACEME
-->

* `other` {RecordableHistogram}

Adds the values from `other` to this histogram.

### `histogram.record(val)`

<!-- YAML
Expand Down
Loading

0 comments on commit 23637e9

Please sign in to comment.