@@ -523,6 +523,38 @@ added: v8.5.0
523523Returns a list of ` PerformanceEntry ` objects in chronological order
524524with respect to ` performanceEntry.startTime ` .
525525
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+
526558### ` performanceObserverEntryList.getEntriesByName(name[, type]) `
527559<!-- YAML
528560added: v8.5.0
@@ -537,6 +569,46 @@ with respect to `performanceEntry.startTime` whose `performanceEntry.name` is
537569equal to ` name ` , and optionally, whose ` performanceEntry.entryType ` is equal to
538570` type ` .
539571
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+
540612### ` performanceObserverEntryList.getEntriesByType(type) `
541613<!-- YAML
542614added: v8.5.0
@@ -549,6 +621,38 @@ Returns a list of `PerformanceEntry` objects in chronological order
549621with respect to ` performanceEntry.startTime ` whose ` performanceEntry.entryType `
550622is equal to ` type ` .
551623
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+
552656## ` perf_hooks.monitorEventLoopDelay([options]) `
553657<!-- YAML
554658added: v11.10.0
0 commit comments