@@ -55,6 +55,17 @@ added: v8.5.0
55
55
If ` name ` is not provided, removes all ` PerformanceMark ` objects from the
56
56
Performance Timeline. If ` name ` is provided, removes only the named mark.
57
57
58
+ ### ` performance.clearMeasures([name]) `
59
+
60
+ <!-- YAML
61
+ added: v16.7.0
62
+ -->
63
+
64
+ * ` name ` {string}
65
+
66
+ If ` name ` is not provided, removes all ` PerformanceMeasure ` objects from the
67
+ Performance Timeline. If ` name ` is provided, removes only the named mark.
68
+
58
69
### ` performance.eventLoopUtilization([utilization1[, utilization2]]) `
59
70
60
71
<!-- YAML
@@ -118,6 +129,47 @@ Passing in a user-defined object instead of the result of a previous call to
118
129
` eventLoopUtilization() ` will lead to undefined behavior. The return values
119
130
are not guaranteed to reflect any correct state of the event loop.
120
131
132
+ ### ` performance.getEntries() `
133
+
134
+ <!-- YAML
135
+ added: v16.7.0
136
+ -->
137
+
138
+ * Returns: {PerformanceEntry\[ ] }
139
+
140
+ Returns a list of ` PerformanceEntry ` objects in chronological order with
141
+ respect to ` performanceEntry.startTime ` . If you are only interested in
142
+ performance entries of certain types or that have certain names, see
143
+ ` performance.getEntriesByType() ` and ` performance.getEntriesByName() ` .
144
+
145
+ ### ` performance.getEntriesByName(name[, type]) `
146
+
147
+ <!-- YAML
148
+ added: v16.7.0
149
+ -->
150
+
151
+ * ` name ` {string}
152
+ * ` type ` {string}
153
+ * Returns: {PerformanceEntry\[ ] }
154
+
155
+ Returns a list of ` PerformanceEntry ` objects in chronological order
156
+ with respect to ` performanceEntry.startTime ` whose ` performanceEntry.name ` is
157
+ equal to ` name ` , and optionally, whose ` performanceEntry.entryType ` is equal to
158
+ ` type ` .
159
+
160
+ ### ` performance.getEntriesByType(type) `
161
+
162
+ <!-- YAML
163
+ added: v16.7.0
164
+ -->
165
+
166
+ * ` type ` {string}
167
+ * Returns: {PerformanceEntry\[ ] }
168
+
169
+ Returns a list of ` PerformanceEntry ` objects in chronological order
170
+ with respect to ` performanceEntry.startTime ` whose ` performanceEntry.entryType `
171
+ is equal to ` type ` .
172
+
121
173
### ` performance.mark([name[, options]]) `
122
174
123
175
<!-- YAML
@@ -140,6 +192,12 @@ Creates a new `PerformanceMark` entry in the Performance Timeline. A
140
192
` performanceEntry.duration ` is always ` 0 ` . Performance marks are used
141
193
to mark specific significant moments in the Performance Timeline.
142
194
195
+ The created ` PerformanceMark ` entry is put in the global Performance Timeline
196
+ and can be queried with ` performance.getEntries ` ,
197
+ ` performance.getEntriesByName ` , and ` performance.getEntriesByType ` . When the
198
+ observation is performed, the entries should be cleared from the global
199
+ Performance Timeline manually with ` performance.clearMarks ` .
200
+
143
201
### ` performance.measure(name[, startMarkOrOptions[, endMark]]) `
144
202
145
203
<!-- YAML
@@ -183,6 +241,12 @@ in the Performance Timeline or any of the timestamp properties provided by the
183
241
if no parameter is passed, otherwise if the named ` endMark ` does not exist, an
184
242
error will be thrown.
185
243
244
+ The created ` PerformanceMeasure ` entry is put in the global Performance Timeline
245
+ and can be queried with ` performance.getEntries ` ,
246
+ ` performance.getEntriesByName ` , and ` performance.getEntriesByType ` . When the
247
+ observation is performed, the entries should be cleared from the global
248
+ Performance Timeline manually with ` performance.clearMeasures ` .
249
+
186
250
### ` performance.nodeTiming `
187
251
188
252
<!-- YAML
@@ -258,6 +322,9 @@ const wrapped = performance.timerify(someFunction);
258
322
259
323
const obs = new PerformanceObserver ((list ) => {
260
324
console .log (list .getEntries ()[0 ].duration );
325
+
326
+ performance .clearMarks ();
327
+ performance .clearMeasures ();
261
328
obs .disconnect ();
262
329
});
263
330
obs .observe ({ entryTypes: [' function' ] });
@@ -585,6 +652,9 @@ const {
585
652
586
653
const obs = new PerformanceObserver ((list , observer ) => {
587
654
console .log (list .getEntries ());
655
+
656
+ performance .clearMarks ();
657
+ performance .clearMeasures ();
588
658
observer .disconnect ();
589
659
});
590
660
obs .observe ({ entryTypes: [' mark' ], buffered: true });
@@ -700,6 +770,9 @@ const obs = new PerformanceObserver((perfObserverList, observer) => {
700
770
* }
701
771
* ]
702
772
*/
773
+
774
+ performance .clearMarks ();
775
+ performance .clearMeasures ();
703
776
observer .disconnect ();
704
777
});
705
778
obs .observe ({ type: ' mark' });
@@ -755,6 +828,9 @@ const obs = new PerformanceObserver((perfObserverList, observer) => {
755
828
* ]
756
829
*/
757
830
console .log (perfObserverList .getEntriesByName (' test' , ' measure' )); // []
831
+
832
+ performance .clearMarks ();
833
+ performance .clearMeasures ();
758
834
observer .disconnect ();
759
835
});
760
836
obs .observe ({ entryTypes: [' mark' , ' measure' ] });
@@ -800,6 +876,8 @@ const obs = new PerformanceObserver((perfObserverList, observer) => {
800
876
* }
801
877
* ]
802
878
*/
879
+ performance .clearMarks ();
880
+ performance .clearMeasures ();
803
881
observer .disconnect ();
804
882
});
805
883
obs .observe ({ type: ' mark' });
@@ -1133,6 +1211,7 @@ hook.enable();
1133
1211
const obs = new PerformanceObserver ((list , observer ) => {
1134
1212
console .log (list .getEntries ()[0 ]);
1135
1213
performance .clearMarks ();
1214
+ performance .clearMeasures ();
1136
1215
observer .disconnect ();
1137
1216
});
1138
1217
obs .observe ({ entryTypes: [' measure' ], buffered: true });
@@ -1166,6 +1245,8 @@ const obs = new PerformanceObserver((list) => {
1166
1245
entries .forEach ((entry ) => {
1167
1246
console .log (` require('${ entry[0 ]} ')` , entry .duration );
1168
1247
});
1248
+ performance .clearMarks ();
1249
+ performance .clearMeasures ();
1169
1250
obs .disconnect ();
1170
1251
});
1171
1252
obs .observe ({ entryTypes: [' function' ], buffered: true });
0 commit comments