@@ -8,12 +8,13 @@ export class SuiteRunner {
8
8
#suite;
9
9
#client;
10
10
#suiteResults;
11
+ #prepareTime = 0 ;
11
12
12
13
constructor ( frame , page , params , suite , client , measuredValues ) {
13
14
// FIXME: Create SuiteRunner-local measuredValues.
14
15
this . #suiteResults = measuredValues . tests [ suite . name ] ;
15
16
if ( ! this . #suiteResults) {
16
- this . #suiteResults = { tests : { } , total : 0 } ;
17
+ this . #suiteResults = { tests : { } , prepare : 0 , total : 0 } ;
17
18
measuredValues . tests [ suite . name ] = this . #suiteResults;
18
19
}
19
20
this . #frame = frame ;
@@ -62,7 +63,8 @@ export class SuiteRunner {
62
63
await this . #suite. prepare ( this . #page) ;
63
64
performance . mark ( suitePrepareEndLabel ) ;
64
65
65
- performance . measure ( `suite-${ suiteName } -prepare` , suitePrepareStartLabel , suitePrepareEndLabel ) ;
66
+ const entry = performance . measure ( `suite-${ suiteName } -prepare` , suitePrepareStartLabel , suitePrepareEndLabel ) ;
67
+ this . #prepareTime = entry . duration ;
66
68
}
67
69
68
70
async _runSuite ( ) {
@@ -83,17 +85,19 @@ export class SuiteRunner {
83
85
performance . mark ( suiteEndLabel ) ;
84
86
85
87
performance . measure ( `suite-${ suiteName } ` , suiteStartLabel , suiteEndLabel ) ;
86
- this . _validateSuiteTotal ( ) ;
88
+ this . _validateSuiteResults ( ) ;
87
89
await this . _updateClient ( ) ;
88
90
}
89
91
90
- _validateSuiteTotal ( ) {
92
+ _validateSuiteResults ( ) {
91
93
// When the test is fast and the precision is low (for example with Firefox'
92
94
// privacy.resistFingerprinting preference), it's possible that the measured
93
95
// total duration for an entire is 0.
94
- const suiteTotal = this . #suiteResults. total ;
96
+ const { suiteTotal, suitePrepare } = this . #suiteResults. total ;
95
97
if ( suiteTotal === 0 )
96
98
throw new Error ( `Got invalid 0-time total for suite ${ this . #suite. name } : ${ suiteTotal } ` ) ;
99
+ if ( this . #params. measurePrepare && suitePrepare === 0 )
100
+ throw new Error ( `Got invalid 0-time prepare time for suite ${ this . #suite. name } : ${ suitePrepare } ` ) ;
97
101
}
98
102
99
103
async _loadFrame ( ) {
@@ -110,9 +114,13 @@ export class SuiteRunner {
110
114
if ( this . #suite === WarmupSuite )
111
115
return ;
112
116
113
- const total = syncTime + asyncTime ;
114
- this . #suiteResults. tests [ test . name ] = { tests : { Sync : syncTime , Async : asyncTime } , total : total } ;
115
- this . #suiteResults. total += total ;
117
+ let total = syncTime + asyncTime ;
118
+ this . #suiteResults. tests [ test . name ] = {
119
+ tests : { Sync : syncTime , Async : asyncTime } ,
120
+ total : total ,
121
+ } ;
122
+ this . #suiteResults. prepare = this . #prepareTime;
123
+ this . #suiteResults. total = total ;
116
124
} ;
117
125
118
126
async _updateClient ( suite = this . #suite) {
@@ -123,6 +131,7 @@ export class SuiteRunner {
123
131
124
132
export class RemoteSuiteRunner extends SuiteRunner {
125
133
#appId;
134
+ #prepareTime;
126
135
127
136
get appId ( ) {
128
137
return this . #appId;
@@ -163,7 +172,8 @@ export class RemoteSuiteRunner extends SuiteRunner {
163
172
164
173
performance . mark ( suitePrepareEndLabel ) ;
165
174
166
- performance . measure ( `suite-${ suiteName } -prepare` , suitePrepareStartLabel , suitePrepareEndLabel ) ;
175
+ const entry = performance . measure ( `suite-${ suiteName } -prepare` , suitePrepareStartLabel , suitePrepareEndLabel ) ;
176
+ this . #prepareTime = entry . duration ;
167
177
}
168
178
169
179
async _runSuite ( ) {
@@ -177,9 +187,10 @@ export class RemoteSuiteRunner extends SuiteRunner {
177
187
...response . result . tests ,
178
188
} ;
179
189
180
- this . suiteResults . total += response . result . total ;
190
+ this . suiteResults . prepare = this . #prepareTime;
191
+ this . suiteResults . total = response . result . total ;
181
192
182
- this . _validateSuiteTotal ( ) ;
193
+ this . _validateSuiteResults ( ) ;
183
194
await this . _updateClient ( ) ;
184
195
}
185
196
0 commit comments