Skip to content

Commit dbbea1a

Browse files
committed
Fix prefetchResources ref counting for GroupedBenchmark
1 parent 7b54891 commit dbbea1a

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

JetStreamDriver.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class Driver {
262262

263263
if (isInBrowser && globalThis.prefetchResources) {
264264
const cache = JetStream.blobDataCache;
265-
for (const file of benchmark.plan.files) {
265+
for (const file of benchmark.files) {
266266
const blobData = cache[file];
267267
blobData.refCount--;
268268
if (!blobData.refCount)
@@ -709,6 +709,7 @@ class Benchmark {
709709
}
710710

711711
get name() { return this.plan.name; }
712+
get files() { return this.plan.files; }
712713

713714
get isDone() {
714715
return this._state == BenchmarkState.DONE || this._state == BenchmarkState.ERROR;
@@ -1148,17 +1149,37 @@ class GroupedBenchmark extends Benchmark {
11481149
benchmark.prefetchResourcesForShell();
11491150
}
11501151

1152+
get files() {
1153+
let files = [];
1154+
for (const benchmark of this.benchmarks)
1155+
files = files.concat(benchmark.files);
1156+
return files;
1157+
}
1158+
11511159
async run() {
1160+
this._state = BenchmarkState.PREPARE;
11521161
performance.mark(this.name);
11531162
this.startTime = performance.now();
11541163

1155-
for (const benchmark of this.benchmarks)
1156-
await benchmark.run();
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+
}
11571177

11581178
this.endTime = performance.now();
11591179
performance.measure(this.name, this.name);
11601180

11611181
this.processResults();
1182+
this._state = BenchmarkState.DONE;
11621183
}
11631184

11641185
processResults() {

0 commit comments

Comments
 (0)