@@ -523,6 +523,38 @@ added: v8.5.0
523
523
Returns a list of ` PerformanceEntry ` objects in chronological order
524
524
with respect to ` performanceEntry.startTime ` .
525
525
526
+ ``` js
527
+ const {
528
+ performance ,
529
+ PerformanceObserver
530
+ } = require (' perf_hooks' );
531
+
532
+ const obs = new PerformanceObserver ((perfObserverList , observer ) => {
533
+ console .log (perfObserverList .getEntries ());
534
+ /**
535
+ * [
536
+ * PerformanceEntry {
537
+ * name: 'test',
538
+ * entryType: 'mark',
539
+ * startTime: 81.465639,
540
+ * duration: 0
541
+ * },
542
+ * PerformanceEntry {
543
+ * name: 'meow',
544
+ * entryType: 'mark',
545
+ * startTime: 81.860064,
546
+ * duration: 0
547
+ * }
548
+ * ]
549
+ */
550
+ observer .disconnect ();
551
+ });
552
+ obs .observe ({ entryTypes: [' mark' ], buffered: true });
553
+
554
+ performance .mark (' test' );
555
+ performance .mark (' meow' );
556
+ ```
557
+
526
558
### ` performanceObserverEntryList.getEntriesByName(name[, type]) `
527
559
<!-- YAML
528
560
added: v8.5.0
@@ -537,6 +569,46 @@ with respect to `performanceEntry.startTime` whose `performanceEntry.name` is
537
569
equal to ` name ` , and optionally, whose ` performanceEntry.entryType ` is equal to
538
570
` type ` .
539
571
572
+ ``` js
573
+ const {
574
+ performance ,
575
+ PerformanceObserver
576
+ } = require (' perf_hooks' );
577
+
578
+ const obs = new PerformanceObserver ((perfObserverList , observer ) => {
579
+ console .log (perfObserverList .getEntriesByName (' meow' ));
580
+ /**
581
+ * [
582
+ * PerformanceEntry {
583
+ * name: 'meow',
584
+ * entryType: 'mark',
585
+ * startTime: 98.545991,
586
+ * duration: 0
587
+ * }
588
+ * ]
589
+ */
590
+ console .log (perfObserverList .getEntriesByName (' nope' )); // []
591
+
592
+ console .log (perfObserverList .getEntriesByName (' test' , ' mark' ));
593
+ /**
594
+ * [
595
+ * PerformanceEntry {
596
+ * name: 'test',
597
+ * entryType: 'mark',
598
+ * startTime: 63.518931,
599
+ * duration: 0
600
+ * }
601
+ * ]
602
+ */
603
+ console .log (perfObserverList .getEntriesByName (' test' , ' measure' )); // []
604
+ observer .disconnect ();
605
+ });
606
+ obs .observe ({ entryTypes: [' mark' , ' measure' ], buffered: true });
607
+
608
+ performance .mark (' test' );
609
+ performance .mark (' meow' );
610
+ ```
611
+
540
612
### ` performanceObserverEntryList.getEntriesByType(type) `
541
613
<!-- YAML
542
614
added: v8.5.0
@@ -549,6 +621,38 @@ Returns a list of `PerformanceEntry` objects in chronological order
549
621
with respect to ` performanceEntry.startTime ` whose ` performanceEntry.entryType `
550
622
is equal to ` type ` .
551
623
624
+ ``` js
625
+ const {
626
+ performance ,
627
+ PerformanceObserver
628
+ } = require (' perf_hooks' );
629
+
630
+ const obs = new PerformanceObserver ((perfObserverList , observer ) => {
631
+ console .log (perfObserverList .getEntriesByType (' mark' ));
632
+ /**
633
+ * [
634
+ * PerformanceEntry {
635
+ * name: 'test',
636
+ * entryType: 'mark',
637
+ * startTime: 55.897834,
638
+ * duration: 0
639
+ * },
640
+ * PerformanceEntry {
641
+ * name: 'meow',
642
+ * entryType: 'mark',
643
+ * startTime: 56.350146,
644
+ * duration: 0
645
+ * }
646
+ * ]
647
+ */
648
+ observer .disconnect ();
649
+ });
650
+ obs .observe ({ entryTypes: [' mark' ], buffered: true });
651
+
652
+ performance .mark (' test' );
653
+ performance .mark (' meow' );
654
+ ```
655
+
552
656
## ` perf_hooks.monitorEventLoopDelay([options]) `
553
657
<!-- YAML
554
658
added: v11.10.0
0 commit comments