Skip to content

Commit 3424bb8

Browse files
committed
Add a new GroupedBenchmark that runs a series of benchmarks.
Use this for all the SunSpider tests. WIP Only note is that `subScores` re-computes everything every time because it's called before the benchmark runs.
1 parent 7ed6f16 commit 3424bb8

File tree

1 file changed

+70
-2
lines changed

1 file changed

+70
-2
lines changed

JetStreamDriver.js

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,69 @@ class Benchmark {
11211121
}
11221122
};
11231123

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+
11241187
class DefaultBenchmark extends Benchmark {
11251188
constructor(...args) {
11261189
super(...args);
@@ -2426,15 +2489,20 @@ const SUNSPIDER_TESTS = [
24262489
"string-unpack-code",
24272490
"tagcloud",
24282491
];
2492+
let SUNSPIDER_BENCHMARKS = [];
24292493
for (const test of SUNSPIDER_TESTS) {
2430-
BENCHMARKS.push(new DefaultBenchmark({
2494+
SUNSPIDER_BENCHMARKS.push(new DefaultBenchmark({
24312495
name: `${test}-SP`,
24322496
files: [
24332497
`./SunSpider/${test}.js`
24342498
],
2435-
tags: ["Default", "SunSpider"],
2499+
tags: [],
24362500
}));
24372501
}
2502+
BENCHMARKS.push(new GroupedBenchmark({
2503+
name: "Sunspider",
2504+
tags: ["Default", "SunSpider"],
2505+
}, SUNSPIDER_BENCHMARKS))
24382506

24392507
// WTB (Web Tooling Benchmark) tests
24402508
const WTB_TESTS = [

0 commit comments

Comments
 (0)