@@ -56,42 +56,17 @@ assert(inited < 15000);
56
56
assert . strictEqual ( performance . nodeTiming . name , 'node' ) ;
57
57
assert . strictEqual ( performance . nodeTiming . entryType , 'node' ) ;
58
58
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 ;
84
60
function checkNodeTiming ( props ) {
85
61
console . log ( props ) ;
86
62
87
63
for ( const prop of Object . keys ( props ) ) {
88
64
if ( props [ prop ] . around !== undefined ) {
89
65
assert . strictEqual ( typeof performance . nodeTiming [ prop ] , 'number' ) ;
90
66
const delta = performance . nodeTiming [ prop ] - props [ prop ] . around ;
91
- const delay = 1000 + timeoutDelay ;
92
67
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 } `
95
70
) ;
96
71
} else {
97
72
assert . strictEqual ( performance . nodeTiming [ prop ] , props [ prop ] ,
@@ -108,28 +83,26 @@ checkNodeTiming({
108
83
duration : { around : performance . now ( ) } ,
109
84
nodeStart : { around : 0 } ,
110
85
v8Start : { around : 0 } ,
111
- bootstrapComplete : { around : inited } ,
86
+ bootstrapComplete : { around : inited , delay : 2500 } ,
112
87
environment : { around : 0 } ,
113
88
loopStart : - 1 ,
114
89
loopExit : - 1
115
90
} ) ;
116
91
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 ) ;
133
106
134
107
process . on ( 'exit' , ( ) => {
135
108
checkNodeTiming ( {
@@ -139,9 +112,9 @@ process.on('exit', () => {
139
112
duration : { around : performance . now ( ) } ,
140
113
nodeStart : { around : 0 } ,
141
114
v8Start : { around : 0 } ,
142
- bootstrapComplete : { around : inited } ,
115
+ bootstrapComplete : { around : inited , delay : 2500 } ,
143
116
environment : { around : 0 } ,
144
- loopStart : { around : inited } ,
117
+ loopStart : { around : inited , delay : 2500 } ,
145
118
loopExit : { around : performance . now ( ) }
146
119
} ) ;
147
120
} ) ;
0 commit comments