diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index bb22c09fddd7de..49ca5cb5425d6a 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -523,6 +523,38 @@ added: v8.5.0 Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`. +```js +const { + performance, + PerformanceObserver +} = require('perf_hooks'); + +const obs = new PerformanceObserver((perfObserverList, observer) => { + console.log(perfObserverList.getEntries()); + /** + * [ + * PerformanceEntry { + * name: 'test', + * entryType: 'mark', + * startTime: 81.465639, + * duration: 0 + * }, + * PerformanceEntry { + * name: 'meow', + * entryType: 'mark', + * startTime: 81.860064, + * duration: 0 + * } + * ] + */ + observer.disconnect(); +}); +obs.observe({ entryTypes: ['mark'], buffered: true }); + +performance.mark('test'); +performance.mark('meow'); +``` + ### `performanceObserverEntryList.getEntriesByName(name[, type])`