@@ -56,42 +56,17 @@ assert(inited < 15000);
5656assert . strictEqual ( performance . nodeTiming . name , 'node' ) ;
5757assert . strictEqual ( performance . nodeTiming . entryType , 'node' ) ;
5858
59- let timeoutDelay = 111 ; // An extra of 111 ms for the first call.
60-
61- function checkDelay ( cb ) {
62- const defaultTimeout = 1 ;
63- const timer = setInterval ( checkDelay , defaultTimeout ) ;
64- const timeouts = 10 ;
65-
66- const now = getTime ( ) ;
67- let resolved = 0 ;
68-
69- function checkDelay ( ) {
70- resolved ++ ;
71- if ( resolved === timeouts ) {
72- clearInterval ( timer ) ;
73- timeoutDelay = getTime ( ) - now ;
74- cb ( ) ;
75- }
76- }
77- }
78-
79- function getTime ( ) {
80- const ts = process . hrtime ( ) ;
81- return Math . ceil ( ( ts [ 0 ] * 1e3 ) + ( ts [ 1 ] / 1e6 ) ) ;
82- }
83-
59+ const delay = 250 ;
8460function checkNodeTiming ( props ) {
8561 console . log ( props ) ;
8662
8763 for ( const prop of Object . keys ( props ) ) {
8864 if ( props [ prop ] . around !== undefined ) {
8965 assert . strictEqual ( typeof performance . nodeTiming [ prop ] , 'number' ) ;
9066 const delta = performance . nodeTiming [ prop ] - props [ prop ] . around ;
91- const delay = 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
134107process . 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