From 843867a08b5edf2f92d63191cb6303facb75fb1e Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Sat, 23 Nov 2024 16:36:49 -0500 Subject: [PATCH] chore: fix benchmark runner --- scripts/bench-file/src/main.ts | 2 +- scripts/bench-file/vitest.config.ts | 12 ------------ scripts/benchmarks/src/runner.ts | 19 ++++++++----------- 3 files changed, 9 insertions(+), 24 deletions(-) delete mode 100644 scripts/bench-file/vitest.config.ts diff --git a/scripts/bench-file/src/main.ts b/scripts/bench-file/src/main.ts index 10a8cb0b..19cdcea1 100644 --- a/scripts/bench-file/src/main.ts +++ b/scripts/bench-file/src/main.ts @@ -13,7 +13,7 @@ async function main() { watch: false, pool: 'vmThreads', includeTaskLocation: true, - config: new URL('../vitest.config.ts', import.meta.url).pathname, + config: new URL('../../../vitest.config.ts', import.meta.url).pathname, benchmark: { reporters: [ reportToBenchmarkHandler(report => { diff --git a/scripts/bench-file/vitest.config.ts b/scripts/bench-file/vitest.config.ts deleted file mode 100644 index ec3da757..00000000 --- a/scripts/bench-file/vitest.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineConfig } from 'vitest/config' - -const resolve = (specifier: string) => - new URL(import.meta.resolve(specifier)).pathname - -export default defineConfig({ - resolve: { - alias: { - 'radashi/typed/isArray.ts': resolve('../../src/typed/isArray.ts'), - }, - }, -}) diff --git a/scripts/benchmarks/src/runner.ts b/scripts/benchmarks/src/runner.ts index 80ce26ef..084f4ef8 100644 --- a/scripts/benchmarks/src/runner.ts +++ b/scripts/benchmarks/src/runner.ts @@ -1,17 +1,14 @@ import { execa } from 'execa' import type { BenchmarkReport } from './reporter.ts' -const tsx = './scripts/benchmarks/node_modules/.bin/tsx' -const runner = './scripts/benchmarks/vitest-bench.ts' - -export function runVitest(file: string) { +export async function runVitest(file: string) { console.log(`Running benchmarks in ./${file}`) - - return execa(tsx, [runner, file], { reject: false }).then(result => { - if (result.exitCode !== 0) { - console.error(result.stderr) - throw new Error('Benchmark failed. See above for details.') - } - return JSON.parse(result.stdout) as BenchmarkReport[] + const result = await execa('node', ['scripts/run', 'bench-file', file], { + reject: false, }) + if (result.exitCode !== 0) { + console.error(result.stderr) + throw new Error('Benchmark failed. See above for details.') + } + return JSON.parse(result.stdout) as BenchmarkReport[] }