diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index d035a14feec04f..0fb87004234e29 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -521,6 +521,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])`