GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: improve perf_hooks docs · nodejs/node@8cf280d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • perf_hooks.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/perf_hooks.md‎

Copy file name to clipboardExpand all lines: doc/api/perf_hooks.md
+104Lines changed: 104 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,38 @@ added: v8.5.0
523523
Returns a list of `PerformanceEntry` objects in chronological order
524524
with 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
528560
added: v8.5.0
@@ -537,6 +569,46 @@ with respect to `performanceEntry.startTime` whose `performanceEntry.name` is
537569
equal 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
542614
added: v8.5.0
@@ -549,6 +621,38 @@ Returns a list of `PerformanceEntry` objects in chronological order
549621
with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`
550622
is 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
554658
added: v11.10.0

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.