Skip to content

Commit 65f2102

Browse files
committed
measure total duration per benchmark
1 parent 6d06f80 commit 65f2102

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

webdriver-ts/src/forkedBenchmarkRunnerPuppeteer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { startBrowser } from "./puppeteerAccess.js";
1313
import { computeResultsCPU, computeResultsJS, computeResultsPaint, fileNameTrace } from "./timeline.js";
1414
import * as fs from "node:fs";
15+
import { performance } from "node:perf_hooks";
1516

1617
let config: Config = defaultConfig;
1718

@@ -283,21 +284,23 @@ export async function executeBenchmark(
283284
benchmarkId: string,
284285
benchmarkOptions: BenchmarkOptions
285286
): Promise<ErrorAndWarning<any>> {
287+
const startTime = performance.now();
286288
let runBenchmarks: Array<BenchmarkPuppeteer> = benchmarks.filter(
287289
(b) =>
288290
benchmarkId === b.benchmarkInfo.id && (b instanceof CPUBenchmarkPuppeteer || b instanceof MemBenchmarkPuppeteer)
289291
) as Array<BenchmarkPuppeteer>;
290292
if (runBenchmarks.length != 1) throw `Benchmark name ${benchmarkId} is not unique (puppeteer)`;
291293

292294
let benchmark = runBenchmarks[0];
293-
294295
let errorAndWarnings: ErrorAndWarning<any>;
295296
if (benchmark.type == BenchmarkType.CPU) {
296297
errorAndWarnings = await runCPUBenchmark(framework, benchmark as CPUBenchmarkPuppeteer, benchmarkOptions);
297298
} else {
298299
errorAndWarnings = await runMemBenchmark(framework, benchmark as MemBenchmarkPuppeteer, benchmarkOptions);
299300
}
300301
if (config.LOG_DEBUG) console.log("benchmark finished - got errors promise", errorAndWarnings);
302+
const duration = performance.now() - startTime;
303+
console.log(`=> Duration for ${benchmark.benchmarkInfo.id} and framework ${framework.name}: ${duration.toFixed(2)} ms`)
301304
return errorAndWarnings;
302305
}
303306

0 commit comments

Comments
 (0)