@@ -11,7 +11,8 @@ export interface BenchmarkInfo {
1111 type : BenchmarkType ;
1212 label : string ;
1313 description : string ;
14- throttleCPU ?: number
14+ throttleCPU ?: number ;
15+ allowBatching : boolean ;
1516}
1617
1718export abstract class Benchmark {
@@ -20,13 +21,15 @@ export abstract class Benchmark {
2021 label : string ;
2122 description : string ;
2223 throttleCPU ?: number ;
24+ allowBatching : boolean ;
2325
2426 constructor ( public benchmarkInfo : BenchmarkInfo ) {
2527 this . id = benchmarkInfo . id ;
2628 this . type = benchmarkInfo . type ;
2729 this . label = benchmarkInfo . label ;
2830 this . description = benchmarkInfo . description ;
2931 this . throttleCPU = benchmarkInfo . throttleCPU ;
32+ this . allowBatching = benchmarkInfo . allowBatching ;
3033 }
3134 abstract init ( driver : WebDriver , framework : FrameworkData ) : Promise < any > ;
3235 abstract run ( driver : WebDriver , framework : FrameworkData ) : Promise < any > ;
@@ -54,7 +57,8 @@ const benchRun = new class extends Benchmark {
5457 id : "01_run1k" ,
5558 label : "create rows" ,
5659 description : "creating 1,000 rows" ,
57- type : BenchmarkType . CPU
60+ type : BenchmarkType . CPU ,
61+ allowBatching : true
5862 } )
5963 }
6064 async init ( driver : WebDriver ) { await testElementLocatedById ( driver , "add" , SHORT_TIMEOUT ) ; }
@@ -70,7 +74,8 @@ const benchReplaceAll = new class extends Benchmark {
7074 id : "02_replace1k" ,
7175 label : "replace all rows" ,
7276 description : "updating all 1,000 rows (" + config . WARMUP_COUNT + " warmup runs)." ,
73- type : BenchmarkType . CPU
77+ type : BenchmarkType . CPU ,
78+ allowBatching : true
7479 } )
7580 }
7681 async init ( driver : WebDriver ) {
@@ -93,7 +98,8 @@ const benchUpdate = new class extends Benchmark {
9398 label : "partial update" ,
9499 description : "updating every 10th row for 1,000 rows (3 warmup runs). 16x CPU slowdown." ,
95100 type : BenchmarkType . CPU ,
96- throttleCPU : 16
101+ throttleCPU : 16 ,
102+ allowBatching : true
97103 } )
98104 }
99105 async init ( driver : WebDriver ) {
@@ -118,14 +124,15 @@ const benchSelect = new class extends Benchmark {
118124 label : "select row" ,
119125 description : "highlighting a selected row. (" + config . WARMUP_COUNT + " warmup runs). 16x CPU slowdown." ,
120126 type : BenchmarkType . CPU ,
121- throttleCPU : 16
127+ throttleCPU : 16 ,
128+ allowBatching : true
122129 } )
123130 }
124131 async init ( driver : WebDriver ) {
125132 await testElementLocatedById ( driver , "run" , SHORT_TIMEOUT ) ;
126133 await clickElementById ( driver , 'run' ) ;
127134 await testElementLocatedByXpath ( driver , "//tbody/tr[1]/td[2]/a" ) ;
128- for ( let i = 0 ; i <= config . WARMUP_COUNT ; i ++ ) {
135+ for ( let i = 0 ; i <= 10 ; i ++ ) {
129136 await clickElementByXPath ( driver , `//tbody/tr[${ i + 1 } ]/td[2]/a` ) ;
130137 }
131138 }
@@ -142,7 +149,8 @@ const benchSwapRows = new class extends Benchmark {
142149 label : "swap rows" ,
143150 description : "swap 2 rows for table with 1,000 rows. (" + config . WARMUP_COUNT + " warmup runs). 4x CPU slowdown." ,
144151 type : BenchmarkType . CPU ,
145- throttleCPU : 4
152+ throttleCPU : 4 ,
153+ allowBatching : true
146154 } )
147155 }
148156 async init ( driver : WebDriver ) {
@@ -168,7 +176,8 @@ const benchRemove = new class extends Benchmark {
168176 id : "06_remove-one-1k" ,
169177 label : "remove row" ,
170178 description : "removing one row. (" + config . WARMUP_COUNT + " warmup runs)." ,
171- type : BenchmarkType . CPU
179+ type : BenchmarkType . CPU ,
180+ allowBatching : true
172181 } )
173182 }
174183 async init ( driver : WebDriver ) {
@@ -201,7 +210,8 @@ const benchRunBig = new class extends Benchmark {
201210 id : "07_create10k" ,
202211 label : "create many rows" ,
203212 description : "creating 10,000 rows" ,
204- type : BenchmarkType . CPU
213+ type : BenchmarkType . CPU ,
214+ allowBatching : false
205215 } )
206216 }
207217 async init ( driver : WebDriver ) {
@@ -220,7 +230,8 @@ const benchAppendToManyRows = new class extends Benchmark {
220230 label : "append rows to large table" ,
221231 description : "appending 1,000 to a table of 10,000 rows. 2x CPU slowdown" ,
222232 type : BenchmarkType . CPU ,
223- throttleCPU : 2
233+ throttleCPU : 2 ,
234+ allowBatching : false
224235 } )
225236 }
226237 async init ( driver : WebDriver ) {
@@ -241,7 +252,8 @@ const benchClear = new class extends Benchmark {
241252 label : "clear rows" ,
242253 description : "clearing a table with 1,000 rows. 8x CPU slowdown" ,
243254 type : BenchmarkType . CPU ,
244- throttleCPU : 8
255+ throttleCPU : 8 ,
256+ allowBatching : true
245257 } )
246258 }
247259 async init ( driver : WebDriver ) {
@@ -262,6 +274,7 @@ const benchReadyMemory = new class extends Benchmark {
262274 label : "ready memory" ,
263275 description : "Memory usage after page load." ,
264276 type : BenchmarkType . MEM ,
277+ allowBatching : true
265278 } )
266279 }
267280 async init ( driver : WebDriver ) {
@@ -283,6 +296,7 @@ const benchRunMemory = new class extends Benchmark {
283296 label : "run memory" ,
284297 description : "Memory usage after adding 1000 rows." ,
285298 type : BenchmarkType . MEM ,
299+ allowBatching : true
286300 } )
287301 }
288302 async init ( driver : WebDriver ) {
@@ -301,6 +315,7 @@ const benchUpdate5Memory = new class extends Benchmark {
301315 label : "update eatch 10th row for 1k rows (5 cycles)" ,
302316 description : "Memory usage after clicking update every 10th row 5 times" ,
303317 type : BenchmarkType . MEM ,
318+ allowBatching : true
304319 } )
305320 }
306321 async init ( driver : WebDriver ) {
@@ -322,6 +337,7 @@ const benchReplace5Memory = new class extends Benchmark {
322337 label : "replace 1k rows (5 cycles)" ,
323338 description : "Memory usage after clicking create 1000 rows 5 times" ,
324339 type : BenchmarkType . MEM ,
340+ allowBatching : true
325341 } )
326342 }
327343 async init ( driver : WebDriver ) {
@@ -342,6 +358,7 @@ const benchCreateClear5Memory = new class extends Benchmark {
342358 label : "creating/clearing 1k rows (5 cycles)" ,
343359 description : "Memory usage after creating and clearing 1000 rows 5 times" ,
344360 type : BenchmarkType . MEM ,
361+ allowBatching : true
345362 } )
346363 }
347364 async init ( driver : WebDriver ) {
@@ -362,31 +379,35 @@ const benchStartupConsistentlyInteractive: StartupBenchmarkResult = {
362379 label : "consistently interactive" ,
363380 description : "a pessimistic TTI - when the CPU and network are both definitely very idle. (no more CPU tasks over 50ms)" ,
364381 type : BenchmarkType . STARTUP ,
365- property : "TimeToConsistentlyInteractive"
382+ property : "TimeToConsistentlyInteractive" ,
383+ allowBatching : true
366384}
367385
368386const benchStartupBootup : StartupBenchmarkResult = {
369387 id : "32_startup-bt" ,
370388 label : "script bootup time" ,
371389 description : "the total ms required to parse/compile/evaluate all the page's scripts" ,
372390 type : BenchmarkType . STARTUP ,
373- property : "ScriptBootUpTtime"
391+ property : "ScriptBootUpTtime" ,
392+ allowBatching : true
374393}
375394
376395const benchStartupMainThreadWorkCost : StartupBenchmarkResult = {
377396 id : "33_startup-mainthreadcost" ,
378397 label : "main thread work cost" ,
379398 description : "total amount of time spent doing work on the main thread. includes style/layout/etc." ,
380399 type : BenchmarkType . STARTUP ,
381- property : "MainThreadWorkCost"
400+ property : "MainThreadWorkCost" ,
401+ allowBatching : true
382402}
383403
384404const benchStartupTotalBytes : StartupBenchmarkResult = {
385405 id : "34_startup-totalbytes" ,
386406 label : "total kilobyte weight" ,
387407 description : "network transfer cost (post-compression) of all the resources loaded into the page." ,
388408 type : BenchmarkType . STARTUP ,
389- property : "TotalKiloByteWeight"
409+ property : "TotalKiloByteWeight" ,
410+ allowBatching : true
390411}
391412
392413class BenchStartup extends Benchmark {
@@ -396,6 +417,7 @@ class BenchStartup extends Benchmark {
396417 label : "startup time" ,
397418 description : "Time for loading, parsing and starting up" ,
398419 type : BenchmarkType . STARTUP ,
420+ allowBatching : true
399421 } )
400422 }
401423 async init ( driver : WebDriver ) { // not used with lighthouse
0 commit comments