@@ -1121,6 +1121,69 @@ class Benchmark {
1121
1121
}
1122
1122
} ;
1123
1123
1124
+ class GroupedBenchmark extends Benchmark {
1125
+ constructor ( plan , benchmarks ) {
1126
+ super ( plan ) ;
1127
+ assert ( benchmarks . length ) ;
1128
+ for ( const benchmark of benchmarks ) {
1129
+ // FIXME: Tags don't work for grouped tests anyway but if they did then this would be weird and probably wrong.
1130
+ assert ( benchmark . plan . tags . indexOf ( "Default" ) === - 1 , `Grouped benchmark sub-benchmarks shouldn't have the "Default" tag` , benchmark . tags ) ;
1131
+ }
1132
+ benchmarks . sort ( ( a , b ) => a . name . toLowerCase ( ) < b . name . toLowerCase ( ) ? 1 : - 1 ) ;
1133
+ this . benchmarks = benchmarks ;
1134
+ }
1135
+
1136
+ async prefetchResourcesForBrowser ( ) {
1137
+ for ( const benchmark of this . benchmarks )
1138
+ await benchmark . prefetchResourcesForBrowser ( ) ;
1139
+ }
1140
+
1141
+ async retryPrefetchResourcesForBrowser ( ) {
1142
+ for ( const benchmark of this . benchmarks )
1143
+ await benchmark . retryPrefetchResourcesForBrowser ( ) ;
1144
+ }
1145
+
1146
+ prefetchResourcesForShell ( ) {
1147
+ for ( const benchmark of this . benchmarks )
1148
+ benchmark . prefetchResourcesForShell ( ) ;
1149
+ }
1150
+
1151
+ async run ( ) {
1152
+ performance . mark ( this . name ) ;
1153
+ this . startTime = performance . now ( ) ;
1154
+
1155
+ for ( const benchmark of this . benchmarks )
1156
+ await benchmark . run ( ) ;
1157
+
1158
+ this . endTime = performance . now ( ) ;
1159
+ performance . measure ( this . name , this . name ) ;
1160
+
1161
+ this . processResults ( ) ;
1162
+ }
1163
+
1164
+ processResults ( ) {
1165
+ this . results = [ ] ;
1166
+ for ( const benchmark of this . benchmarks )
1167
+ this . results = this . results . concat ( benchmark . results ) ;
1168
+ }
1169
+
1170
+ subScores ( ) {
1171
+ const results = { } ;
1172
+
1173
+ for ( const benchmark of this . benchmarks ) {
1174
+ let scores = benchmark . subScores ( ) ;
1175
+ for ( let subScore in scores ) {
1176
+ results [ subScore ] ??= [ ] ;
1177
+ results [ subScore ] . push ( scores [ subScore ] ) ;
1178
+ }
1179
+ }
1180
+
1181
+ for ( let subScore in results )
1182
+ results [ subScore ] = geomeanScore ( results [ subScore ] ) ;
1183
+ return results ;
1184
+ }
1185
+ } ;
1186
+
1124
1187
class DefaultBenchmark extends Benchmark {
1125
1188
constructor ( ...args ) {
1126
1189
super ( ...args ) ;
@@ -2426,15 +2489,20 @@ const SUNSPIDER_TESTS = [
2426
2489
"string-unpack-code" ,
2427
2490
"tagcloud" ,
2428
2491
] ;
2492
+ let SUNSPIDER_BENCHMARKS = [ ] ;
2429
2493
for ( const test of SUNSPIDER_TESTS ) {
2430
- BENCHMARKS . push ( new DefaultBenchmark ( {
2494
+ SUNSPIDER_BENCHMARKS . push ( new DefaultBenchmark ( {
2431
2495
name : `${ test } -SP` ,
2432
2496
files : [
2433
2497
`./SunSpider/${ test } .js`
2434
2498
] ,
2435
- tags : [ "Default" , "SunSpider" ] ,
2499
+ tags : [ ] ,
2436
2500
} ) ) ;
2437
2501
}
2502
+ BENCHMARKS . push ( new GroupedBenchmark ( {
2503
+ name : "Sunspider" ,
2504
+ tags : [ "Default" , "SunSpider" ] ,
2505
+ } , SUNSPIDER_BENCHMARKS ) )
2438
2506
2439
2507
// WTB (Web Tooling Benchmark) tests
2440
2508
const WTB_TESTS = [
0 commit comments