Skip to content

Commit c021b38

Browse files
jasnelldanielleadams
authored andcommitted
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 <[email protected]> perf_hooks: simplify Histogram constructor options Signed-off-by: James M Snell <[email protected]> PR-URL: #41153 Reviewed-By: Matteo Collina <[email protected]>
1 parent c10fcb1 commit c021b38

9 files changed

+807
-211
lines changed

doc/api/perf_hooks.md

+86-3
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,11 @@ added: v15.9.0
815815
-->
816816

817817
* `options` {Object}
818-
* `min` {number|bigint} The minimum recordable value. Must be an integer
818+
* `lowest` {number|bigint} The lowest discernible value. Must be an integer
819819
value greater than 0. **Default:** `1`.
820-
* `max` {number|bigint} The maximum recordable value. Must be an integer
821-
value greater than `min`. **Default:** `Number.MAX_SAFE_INTEGER`.
820+
* `highest` {number|bigint} The highest recordable value. Must be an integer
821+
value that is equal to or greater than two times `min`.
822+
**Default:** `Number.MAX_SAFE_INTEGER`.
822823
* `figures` {number} The number of accuracy digits. Must be a number between
823824
`1` and `5`. **Default:** `3`.
824825
* Returns {RecordableHistogram}
@@ -868,6 +869,26 @@ console.log(h.percentile(99));
868869
added: v11.10.0
869870
-->
870871

872+
### `histogram.count`
873+
874+
<!-- YAML
875+
added: REPLACEME
876+
-->
877+
878+
* {number}
879+
880+
The number of samples recorded by the histogram.
881+
882+
### `histogram.countBigInt`
883+
884+
<!-- YAML
885+
added: REPLACEME
886+
-->
887+
888+
* {bigint}
889+
890+
The number of samples recorded by the histogram.
891+
871892
### `histogram.exceeds`
872893

873894
<!-- YAML
@@ -879,6 +900,17 @@ added: v11.10.0
879900
The number of times the event loop delay exceeded the maximum 1 hour event
880901
loop delay threshold.
881902

903+
### `histogram.exceedsBigInt`
904+
905+
<!-- YAML
906+
added: REPLACEME
907+
-->
908+
909+
* {bigint}
910+
911+
The number of times the event loop delay exceeded the maximum 1 hour event
912+
loop delay threshold.
913+
882914
### `histogram.max`
883915

884916
<!-- YAML
@@ -889,6 +921,16 @@ added: v11.10.0
889921

890922
The maximum recorded event loop delay.
891923

924+
### `histogram.maxBigInt`
925+
926+
<!-- YAML
927+
added: REPLACEME
928+
-->
929+
930+
* {bigint}
931+
932+
The maximum recorded event loop delay.
933+
892934
### `histogram.mean`
893935

894936
<!-- YAML
@@ -909,6 +951,16 @@ added: v11.10.0
909951

910952
The minimum recorded event loop delay.
911953

954+
### `histogram.minBigInt`
955+
956+
<!-- YAML
957+
added: REPLACEME
958+
-->
959+
960+
* {bigint}
961+
962+
The minimum recorded event loop delay.
963+
912964
### `histogram.percentile(percentile)`
913965

914966
<!-- YAML
@@ -920,6 +972,17 @@ added: v11.10.0
920972

921973
Returns the value at the given percentile.
922974

975+
### `histogram.percentileBigInt(percentile)`
976+
977+
<!-- YAML
978+
added: REPLACEME
979+
-->
980+
981+
* `percentile` {number} A percentile value in the range (0, 100).
982+
* Returns: {bigint}
983+
984+
Returns the value at the given percentile.
985+
923986
### `histogram.percentiles`
924987

925988
<!-- YAML
@@ -930,6 +993,16 @@ added: v11.10.0
930993

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

996+
### `histogram.percentilesBigInt`
997+
998+
<!-- YAML
999+
added: REPLACEME
1000+
-->
1001+
1002+
* {Map}
1003+
1004+
Returns a `Map` object detailing the accumulated percentile distribution.
1005+
9331006
### `histogram.reset()`
9341007

9351008
<!-- YAML
@@ -986,6 +1059,16 @@ implement the `enable()` and `disable()` methods.
9861059
added: v15.9.0
9871060
-->
9881061

1062+
### `histogram.add(other)`
1063+
1064+
<!-- YAML
1065+
added: REPLACEME
1066+
-->
1067+
1068+
* `other` {RecordableHistogram}
1069+
1070+
Adds the values from `other` to this histogram.
1071+
9891072
### `histogram.record(val)`
9901073

9911074
<!-- YAML

0 commit comments

Comments
 (0)