@@ -8,12 +8,13 @@ export class SuiteRunner {
88 #suite;
99 #client;
1010 #suiteResults;
11+ #prepareTime = 0 ;
1112
1213 constructor ( frame , page , params , suite , client , measuredValues ) {
1314 // FIXME: Create SuiteRunner-local measuredValues.
1415 this . #suiteResults = measuredValues . tests [ suite . name ] ;
1516 if ( ! this . #suiteResults) {
16- this . #suiteResults = { tests : { } , total : 0 } ;
17+ this . #suiteResults = { tests : { } , prepare : 0 , total : 0 } ;
1718 measuredValues . tests [ suite . name ] = this . #suiteResults;
1819 }
1920 this . #frame = frame ;
@@ -62,7 +63,8 @@ export class SuiteRunner {
6263 await this . #suite. prepare ( this . #page) ;
6364 performance . mark ( suitePrepareEndLabel ) ;
6465
65- performance . measure ( `suite-${ suiteName } -prepare` , suitePrepareStartLabel , suitePrepareEndLabel ) ;
66+ const entry = performance . measure ( `suite-${ suiteName } -prepare` , suitePrepareStartLabel , suitePrepareEndLabel ) ;
67+ this . #prepareTime = entry . duration ;
6668 }
6769
6870 async _runSuite ( ) {
@@ -83,17 +85,19 @@ export class SuiteRunner {
8385 performance . mark ( suiteEndLabel ) ;
8486
8587 performance . measure ( `suite-${ suiteName } ` , suiteStartLabel , suiteEndLabel ) ;
86- this . _validateSuiteTotal ( ) ;
88+ this . _validateSuiteResults ( ) ;
8789 await this . _updateClient ( ) ;
8890 }
8991
90- _validateSuiteTotal ( ) {
92+ _validateSuiteResults ( ) {
9193 // When the test is fast and the precision is low (for example with Firefox'
9294 // privacy.resistFingerprinting preference), it's possible that the measured
9395 // total duration for an entire is 0.
94- const suiteTotal = this . #suiteResults. total ;
96+ const { suiteTotal, suitePrepare } = this . #suiteResults. total ;
9597 if ( suiteTotal === 0 )
9698 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 } ` ) ;
97101 }
98102
99103 async _loadFrame ( ) {
@@ -110,9 +114,13 @@ export class SuiteRunner {
110114 if ( this . #suite === WarmupSuite )
111115 return ;
112116
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 ;
116124 } ;
117125
118126 async _updateClient ( suite = this . #suite) {
@@ -123,6 +131,7 @@ export class SuiteRunner {
123131
124132export class RemoteSuiteRunner extends SuiteRunner {
125133 #appId;
134+ #prepareTime;
126135
127136 get appId ( ) {
128137 return this . #appId;
@@ -163,7 +172,8 @@ export class RemoteSuiteRunner extends SuiteRunner {
163172
164173 performance . mark ( suitePrepareEndLabel ) ;
165174
166- performance . measure ( `suite-${ suiteName } -prepare` , suitePrepareStartLabel , suitePrepareEndLabel ) ;
175+ const entry = performance . measure ( `suite-${ suiteName } -prepare` , suitePrepareStartLabel , suitePrepareEndLabel ) ;
176+ this . #prepareTime = entry . duration ;
167177 }
168178
169179 async _runSuite ( ) {
@@ -177,9 +187,10 @@ export class RemoteSuiteRunner extends SuiteRunner {
177187 ...response . result . tests ,
178188 } ;
179189
180- this . suiteResults . total += response . result . total ;
190+ this . suiteResults . prepare = this . #prepareTime;
191+ this . suiteResults . total = response . result . total ;
181192
182- this . _validateSuiteTotal ( ) ;
193+ this . _validateSuiteResults ( ) ;
183194 await this . _updateClient ( ) ;
184195 }
185196
0 commit comments