@@ -653,6 +653,22 @@ performance.mark('test');
653
653
performance .mark (' meow' );
654
654
```
655
655
656
+ ## ` perf_hooks.createHistogram([options]) `
657
+ <!-- YAML
658
+ added: REPLACEME
659
+ -->
660
+
661
+ * ` options ` {Object}
662
+ * ` min ` {number|bigint} The minimum recordable value. Must be an integer
663
+ value greater than 0. ** Defaults** : ` 1 ` .
664
+ * ` max ` {number|bigint} The maximum recordable value. Must be an integer
665
+ value greater than ` min ` . ** Defaults** : ` Number.MAX_SAFE_INTEGER ` .
666
+ * ` figures ` {number} The number of accuracy digits. Must be a number between
667
+ ` 1 ` and ` 5 ` . ** Defaults** : ` 3 ` .
668
+ * Returns {RecordableHistogram}
669
+
670
+ Returns a {RecordableHistogram}.
671
+
656
672
## ` perf_hooks.monitorEventLoopDelay([options]) `
657
673
<!-- YAML
658
674
added: v11.10.0
@@ -661,12 +677,12 @@ added: v11.10.0
661
677
* ` options ` {Object}
662
678
* ` resolution ` {number} The sampling rate in milliseconds. Must be greater
663
679
than zero. ** Default:** ` 10 ` .
664
- * Returns: {Histogram }
680
+ * Returns: {IntervalHistogram }
665
681
666
682
_ This property is an extension by Node.js. It is not available in Web browsers._
667
683
668
- Creates a ` Histogram ` object that samples and reports the event loop delay
669
- over time. The delays will be reported in nanoseconds.
684
+ Creates an ` IntervalHistogram ` object that samples and reports the event loop
685
+ delay over time. The delays will be reported in nanoseconds.
670
686
671
687
Using a timer to detect approximate event loop delay works because the
672
688
execution of timers is tied specifically to the lifecycle of the libuv
@@ -689,36 +705,12 @@ console.log(h.percentile(50));
689
705
console .log (h .percentile (99 ));
690
706
```
691
707
692
- ### Class: ` Histogram `
693
- <!-- YAML
694
- added: v11.10.0
695
- -->
696
- Tracks the event loop delay at a given sampling rate. The constructor of
697
- this class not exposed to users.
698
-
699
- _ This property is an extension by Node.js. It is not available in Web browsers._
700
-
701
- #### ` histogram.disable() `
702
- <!-- YAML
703
- added: v11.10.0
704
- -->
705
-
706
- * Returns: {boolean}
707
-
708
- Disables the event loop delay sample timer. Returns ` true ` if the timer was
709
- stopped, ` false ` if it was already stopped.
710
-
711
- #### ` histogram.enable() `
708
+ ## Class: ` Histogram `
712
709
<!-- YAML
713
710
added: v11.10.0
714
711
-->
715
712
716
- * Returns: {boolean}
717
-
718
- Enables the event loop delay sample timer. Returns ` true ` if the timer was
719
- started, ` false ` if it was already started.
720
-
721
- #### ` histogram.exceeds `
713
+ ### ` histogram.exceeds `
722
714
<!-- YAML
723
715
added: v11.10.0
724
716
-->
@@ -728,7 +720,7 @@ added: v11.10.0
728
720
The number of times the event loop delay exceeded the maximum 1 hour event
729
721
loop delay threshold.
730
722
731
- #### ` histogram.max `
723
+ ### ` histogram.max `
732
724
<!-- YAML
733
725
added: v11.10.0
734
726
-->
@@ -737,7 +729,7 @@ added: v11.10.0
737
729
738
730
The maximum recorded event loop delay.
739
731
740
- #### ` histogram.mean `
732
+ ### ` histogram.mean `
741
733
<!-- YAML
742
734
added: v11.10.0
743
735
-->
@@ -746,7 +738,7 @@ added: v11.10.0
746
738
747
739
The mean of the recorded event loop delays.
748
740
749
- #### ` histogram.min `
741
+ ### ` histogram.min `
750
742
<!-- YAML
751
743
added: v11.10.0
752
744
-->
@@ -755,7 +747,7 @@ added: v11.10.0
755
747
756
748
The minimum recorded event loop delay.
757
749
758
- #### ` histogram.percentile(percentile) `
750
+ ### ` histogram.percentile(percentile) `
759
751
<!-- YAML
760
752
added: v11.10.0
761
753
-->
@@ -765,7 +757,7 @@ added: v11.10.0
765
757
766
758
Returns the value at the given percentile.
767
759
768
- #### ` histogram.percentiles `
760
+ ### ` histogram.percentiles `
769
761
<!-- YAML
770
762
added: v11.10.0
771
763
-->
@@ -774,14 +766,14 @@ added: v11.10.0
774
766
775
767
Returns a ` Map ` object detailing the accumulated percentile distribution.
776
768
777
- #### ` histogram.reset() `
769
+ ### ` histogram.reset() `
778
770
<!-- YAML
779
771
added: v11.10.0
780
772
-->
781
773
782
774
Resets the collected histogram data.
783
775
784
- #### ` histogram.stddev `
776
+ ### ` histogram.stddev `
785
777
<!-- YAML
786
778
added: v11.10.0
787
779
-->
@@ -790,6 +782,56 @@ added: v11.10.0
790
782
791
783
The standard deviation of the recorded event loop delays.
792
784
785
+ ## Class: ` IntervalHistogram extends Histogram `
786
+
787
+ A ` Histogram ` that is periodically updated on a given interval.
788
+
789
+ ### ` histogram.disable() `
790
+ <!-- YAML
791
+ added: v11.10.0
792
+ -->
793
+
794
+ * Returns: {boolean}
795
+
796
+ Disables the update interval timer. Returns ` true ` if the timer was
797
+ stopped, ` false ` if it was already stopped.
798
+
799
+ ### ` histogram.enable() `
800
+ <!-- YAML
801
+ added: v11.10.0
802
+ -->
803
+
804
+ * Returns: {boolean}
805
+
806
+ Enables the update interval timer. Returns ` true ` if the timer was
807
+ started, ` false ` if it was already started.
808
+
809
+ ### Cloning an ` IntervalHistogram `
810
+
811
+ {IntervalHistogram} instances can be cloned via {MessagePort}. On the receiving
812
+ end, the histogram is cloned as a plain {Histogram} object that does not
813
+ implement the ` enable() ` and ` disable() ` methods.
814
+
815
+ ## Class: ` RecordableHistogram extends Histogram `
816
+ <!-- YAML
817
+ added: REPLACEME
818
+ -->
819
+
820
+ ### ` histogram.record(val) `
821
+ <!-- YAML
822
+ added: REPLACEME
823
+ -->
824
+
825
+ * ` val ` {number|bigint} The amount to record in the histogram.
826
+
827
+ ### ` histogram.recordDelta() `
828
+ <!-- YAML
829
+ added: REPLACEME
830
+ -->
831
+
832
+ Calculates the amount of time (in nanoseconds) that has passed since the
833
+ previous call to ` recordDelta() ` and records that amount in the histogram.
834
+
793
835
## Examples
794
836
795
837
### Measuring the duration of async operations
0 commit comments