@@ -262,7 +262,7 @@ class Driver {
262
262
263
263
if ( isInBrowser && globalThis . prefetchResources ) {
264
264
const cache = JetStream . blobDataCache ;
265
- for ( const file of benchmark . plan . files ) {
265
+ for ( const file of benchmark . files ) {
266
266
const blobData = cache [ file ] ;
267
267
blobData . refCount -- ;
268
268
if ( ! blobData . refCount )
@@ -709,6 +709,7 @@ class Benchmark {
709
709
}
710
710
711
711
get name ( ) { return this . plan . name ; }
712
+ get files ( ) { return this . plan . files ; }
712
713
713
714
get isDone ( ) {
714
715
return this . _state == BenchmarkState . DONE || this . _state == BenchmarkState . ERROR ;
@@ -1121,6 +1122,89 @@ class Benchmark {
1121
1122
}
1122
1123
} ;
1123
1124
1125
+ class GroupedBenchmark extends Benchmark {
1126
+ constructor ( plan , benchmarks ) {
1127
+ super ( plan ) ;
1128
+ console . assert ( benchmarks . length ) ;
1129
+ for ( const benchmark of benchmarks ) {
1130
+ // FIXME: Tags don't work for grouped tests anyway but if they did then this would be weird and probably wrong.
1131
+ console . assert ( ! benchmark . hasAnyTag ( "Default" ) , `Grouped benchmark sub-benchmarks shouldn't have the "Default" tag` , benchmark . tags ) ;
1132
+ }
1133
+ benchmarks . sort ( ( a , b ) => a . name . toLowerCase ( ) < b . name . toLowerCase ( ) ? 1 : - 1 ) ;
1134
+ this . benchmarks = benchmarks ;
1135
+ }
1136
+
1137
+ async prefetchResourcesForBrowser ( ) {
1138
+ for ( const benchmark of this . benchmarks )
1139
+ await benchmark . prefetchResourcesForBrowser ( ) ;
1140
+ }
1141
+
1142
+ async retryPrefetchResourcesForBrowser ( ) {
1143
+ for ( const benchmark of this . benchmarks )
1144
+ await benchmark . retryPrefetchResourcesForBrowser ( ) ;
1145
+ }
1146
+
1147
+ prefetchResourcesForShell ( ) {
1148
+ for ( const benchmark of this . benchmarks )
1149
+ benchmark . prefetchResourcesForShell ( ) ;
1150
+ }
1151
+
1152
+ get files ( ) {
1153
+ let files = [ ] ;
1154
+ for ( const benchmark of this . benchmarks )
1155
+ files = files . concat ( benchmark . files ) ;
1156
+ return files ;
1157
+ }
1158
+
1159
+ async run ( ) {
1160
+ this . _state = BenchmarkState . PREPARE ;
1161
+ performance . mark ( this . name ) ;
1162
+ this . startTime = performance . now ( ) ;
1163
+
1164
+ let benchmark ;
1165
+ try {
1166
+ this . _state = BenchmarkState . RUNNING ;
1167
+ for ( benchmark of this . benchmarks )
1168
+ await benchmark . run ( ) ;
1169
+ } catch ( e ) {
1170
+ this . _state = BenchmarkState . ERROR ;
1171
+ console . log ( `Error in runCode of grouped benchmark ${ benchmark . name } : ` , e ) ;
1172
+ console . log ( e . stack ) ;
1173
+ throw e ;
1174
+ } finally {
1175
+ this . _state = BenchmarkState . FINALIZE ;
1176
+ }
1177
+
1178
+ this . endTime = performance . now ( ) ;
1179
+ performance . measure ( this . name , this . name ) ;
1180
+
1181
+ this . processResults ( ) ;
1182
+ this . _state = BenchmarkState . DONE ;
1183
+ }
1184
+
1185
+ processResults ( ) {
1186
+ this . results = [ ] ;
1187
+ for ( const benchmark of this . benchmarks )
1188
+ this . results = this . results . concat ( benchmark . results ) ;
1189
+ }
1190
+
1191
+ subScores ( ) {
1192
+ const results = { } ;
1193
+
1194
+ for ( const benchmark of this . benchmarks ) {
1195
+ let scores = benchmark . subScores ( ) ;
1196
+ for ( let subScore in scores ) {
1197
+ results [ subScore ] ??= [ ] ;
1198
+ results [ subScore ] . push ( scores [ subScore ] ) ;
1199
+ }
1200
+ }
1201
+
1202
+ for ( let subScore in results )
1203
+ results [ subScore ] = geomeanScore ( results [ subScore ] ) ;
1204
+ return results ;
1205
+ }
1206
+ } ;
1207
+
1124
1208
class DefaultBenchmark extends Benchmark {
1125
1209
constructor ( ...args ) {
1126
1210
super ( ...args ) ;
@@ -2433,15 +2517,20 @@ const SUNSPIDER_TESTS = [
2433
2517
"string-unpack-code" ,
2434
2518
"tagcloud" ,
2435
2519
] ;
2520
+ let SUNSPIDER_BENCHMARKS = [ ] ;
2436
2521
for ( const test of SUNSPIDER_TESTS ) {
2437
- BENCHMARKS . push ( new DefaultBenchmark ( {
2522
+ SUNSPIDER_BENCHMARKS . push ( new DefaultBenchmark ( {
2438
2523
name : `${ test } -SP` ,
2439
2524
files : [
2440
2525
`./SunSpider/${ test } .js`
2441
2526
] ,
2442
- tags : [ "Default" , "SunSpider" ] ,
2527
+ tags : [ ] ,
2443
2528
} ) ) ;
2444
2529
}
2530
+ BENCHMARKS . push ( new GroupedBenchmark ( {
2531
+ name : "Sunspider" ,
2532
+ tags : [ "Default" , "SunSpider" ] ,
2533
+ } , SUNSPIDER_BENCHMARKS ) )
2445
2534
2446
2535
// WTB (Web Tooling Benchmark) tests
2447
2536
const WTB_TESTS = [
0 commit comments