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 authored and danielleadams committed Feb 1, 2022
1 parent c10fcb1 commit c021b38
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 @@ -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}
Expand Down Expand Up @@ -868,6 +869,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 @@ -879,6 +900,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 @@ -889,6 +921,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 @@ -909,6 +951,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 @@ -920,6 +972,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 @@ -930,6 +993,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 @@ -986,6 +1059,16 @@ implement the `enable()` and `disable()` methods.
added: v15.9.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 c021b38

Please sign in to comment.