blob: 82ff6612c5bf863379de29a7b1f67007d92b7136 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
'use strict';
const common = require('../common');
const {
PerformanceObserver,
performance: {
timerify,
},
} = require('perf_hooks');
const assert = require('assert');
const {
setTimeout: sleep
} = require('timers/promises');
let check = false;
async function doIt() {
await sleep(100);
check = true;
return check;
}
const obs = new PerformanceObserver(common.mustCall((list) => {
const entry = list.getEntries()[0];
assert.strictEqual(entry.name, 'doIt');
assert(check);
obs.disconnect();
}));
obs.observe({ type: 'function' });
const timerified = timerify(doIt);
const res = timerified();
assert(res instanceof Promise);
res.then(common.mustCall(assert));
|