From 1b433ca02ba923a5ceb9a7a7e67e20a263882d93 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 19 Jun 2024 16:11:52 -0400 Subject: [PATCH] WIP --- .gitignore | 2 ++ benchmarking/compare.js | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 4ce5c243c7..1bf7f747b0 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ coverage .DS_Store tmp + +benchmarking/.results diff --git a/benchmarking/compare.js b/benchmarking/compare.js index 4d522292d5..af8714ef86 100644 --- a/benchmarking/compare.js +++ b/benchmarking/compare.js @@ -3,9 +3,13 @@ import { execSync } from 'node:child_process'; import { fileURLToPath } from 'node:url'; import { benchmarks } from './benchmarks.js'; -const results = fileURLToPath(new URL('./.results', import.meta.url)); +if (execSync('git status --porcelain').toString().trim()) { + console.error('Working directory is not clean'); + process.exit(1); +} -console.log(results); +const results = fileURLToPath(new URL('./.results', import.meta.url)); +if (!fs.existsSync(results)) fs.mkdirSync(results); const [ a = execSync('git symbolic-ref --short -q HEAD || git rev-parse --short HEAD').toString().trim(), @@ -30,7 +34,7 @@ async function run() { const results = []; for (const benchmark of benchmarks) { const result = await benchmark(); - console.log(result.name); + console.log(result.benchmark); results.push(result); } return results; @@ -46,6 +50,8 @@ async function run() { // step 2 — run the benchmark on the comparison branch (usually main) { + execSync(`git checkout ${b_hash}`); + b_results = await run(); console.log(b_results); @@ -54,5 +60,6 @@ async function run() { // step 3 — compare the results { + execSync(`git checkout ${a_hash}`); // TODO }