diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index 74f8c115b486d4..7c3144939244b6 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -22,18 +22,18 @@ const { PerformanceObserver, performance } = require('node:perf_hooks'); const obs = new PerformanceObserver((items) => { console.log(items.getEntries()[0].duration); - performance.clearMarks(); }); obs.observe({ type: 'measure' }); performance.measure('Start to Now'); performance.mark('A'); -doSomeLongRunningProcess(() => { +(async function doSomeLongRunningProcess() { + await new Promise(r => setTimeout(r, 5000)); performance.measure('A to Now', 'A'); performance.mark('B'); performance.measure('A to B', 'A', 'B'); -}); +})(); ``` ## `perf_hooks.performance`