0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-performance-measure-detail.js
theanarkh 77710251e1
lib: add toJSON to PerformanceMeasure
PR-URL: https://github.com/nodejs/node/pull/53603
Refs: https://github.com/nodejs/node/issues/53570
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2024-06-29 04:48:23 +00:00

21 lines
554 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const util = require('util');
const { performance, PerformanceObserver } = require('perf_hooks');
const perfObserver = new PerformanceObserver(common.mustCall((items) => {
const entries = items.getEntries();
assert.ok(entries.length === 1);
for (const entry of entries) {
assert.ok(util.inspect(entry).includes('this is detail'));
}
}));
perfObserver.observe({ entryTypes: ['measure'] });
performance.measure('sample', {
detail: 'this is detail',
});