Skip to content

Commit f33d705

Browse files
apapirovskiaddaleax
authored andcommitted
test: fix sequential/test-performance delay
PR-URL: #25695Fixes: #23291 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent ee61ab6 commit f33d705

File tree

1 file changed

+20
-47
lines changed

1 file changed

+20
-47
lines changed

‎test/sequential/test-performance.js‎

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -56,42 +56,17 @@ assert(inited < 15000);
5656
assert.strictEqual(performance.nodeTiming.name,'node');
5757
assert.strictEqual(performance.nodeTiming.entryType,'node');
5858

59-
lettimeoutDelay=111;// An extra of 111 ms for the first call.
60-
61-
functioncheckDelay(cb){
62-
constdefaultTimeout=1;
63-
consttimer=setInterval(checkDelay,defaultTimeout);
64-
consttimeouts=10;
65-
66-
constnow=getTime();
67-
letresolved=0;
68-
69-
functioncheckDelay(){
70-
resolved++;
71-
if(resolved===timeouts){
72-
clearInterval(timer);
73-
timeoutDelay=getTime()-now;
74-
cb();
75-
}
76-
}
77-
}
78-
79-
functiongetTime(){
80-
constts=process.hrtime();
81-
returnMath.ceil((ts[0]*1e3)+(ts[1]/1e6));
82-
}
83-
59+
constdelay=250;
8460
functioncheckNodeTiming(props){
8561
console.log(props);
8662

8763
for(constpropofObject.keys(props)){
8864
if(props[prop].around!==undefined){
8965
assert.strictEqual(typeofperformance.nodeTiming[prop],'number');
9066
constdelta=performance.nodeTiming[prop]-props[prop].around;
91-
constdelay=1000+timeoutDelay;
9267
assert(
93-
Math.abs(delta)<delay,
94-
`${prop}: ${Math.abs(delta)} >= ${delay}`
68+
Math.abs(delta)<(props[prop].delay||delay),
69+
`${prop}: ${Math.abs(delta)} >= ${props[prop].delay||delay}`
9570
);
9671
}else{
9772
assert.strictEqual(performance.nodeTiming[prop],props[prop],
@@ -108,28 +83,26 @@ checkNodeTiming({
10883
duration: {around: performance.now()},
10984
nodeStart: {around: 0},
11085
v8Start: {around: 0},
111-
bootstrapComplete: {around: inited},
86+
bootstrapComplete: {around: inited,delay: 2500},
11287
environment: {around: 0},
11388
loopStart: -1,
11489
loopExit: -1
11590
});
11691

117-
checkDelay(()=>{
118-
setTimeout(()=>{
119-
checkNodeTiming({
120-
name: 'node',
121-
entryType: 'node',
122-
startTime: 0,
123-
duration: {around: performance.now()},
124-
nodeStart: {around: 0},
125-
v8Start: {around: 0},
126-
bootstrapComplete: {around: inited},
127-
environment: {around: 0},
128-
loopStart: {around: inited},
129-
loopExit: -1
130-
});
131-
},1000);
132-
});
92+
setTimeout(()=>{
93+
checkNodeTiming({
94+
name: 'node',
95+
entryType: 'node',
96+
startTime: 0,
97+
duration: {around: performance.now()},
98+
nodeStart: {around: 0},
99+
v8Start: {around: 0},
100+
bootstrapComplete: {around: inited,delay: 2500},
101+
environment: {around: 0},
102+
loopStart: {around: inited,delay: 2500},
103+
loopExit: -1
104+
});
105+
},1000);
133106

134107
process.on('exit',()=>{
135108
checkNodeTiming({
@@ -139,9 +112,9 @@ process.on('exit', () =>{
139112
duration: {around: performance.now()},
140113
nodeStart: {around: 0},
141114
v8Start: {around: 0},
142-
bootstrapComplete: {around: inited},
115+
bootstrapComplete: {around: inited,delay: 2500},
143116
environment: {around: 0},
144-
loopStart: {around: inited},
117+
loopStart: {around: inited,delay: 2500},
145118
loopExit: {around: performance.now()}
146119
});
147120
});

0 commit comments

Comments
(0)