Closed mouhannad-sh closed 3 weeks ago
It looks like the documentation of benchmark.outputFile
is a little outdated. For comparison, you need to use benchmark.outputJson
and benchmark.compare
combo as shown in https://vitest.dev/config/#benchmark-outputJson
# save main branch's result
git checkout main
vitest bench --outputJson main.json
# change a branch and compare against main
git checkout feature
vitest bench --compare main.json
Technically, you can put a same file to both options like below, but this will always overwrite bench.json
, so that's a bit different from the intended usage.
export default defineConfig({
test: {
benchmark: {
outputJson: './bench.json',
compare: './bench.json'
},
},
});
Thanks @hi-ogawa this works with a small gotcha
It will fail at the first runtime if there's no bench.json
file present. might be worth adding this detail to the docs too
I updated the Stackblitz link to reflect this thanks a bunch !
Describe the bug
Hi 👋🏻
Thank you for adding the ability to run benchmarking inside of Vitest, it's 🔥
In the documentation for benchmark outputfile the
json
reporter was mentioned as the only way to output benchmark results and compare against previous results via the compare option However, when I follow the instructions to configure my vitest benchmarks I get this errorAdditionally, I noticed that the
BenchmarkBuiltinReporters
only include "default" and "verbose" and both don't seem to allow us to output benchmark results into a file.I would like to be able to export the benchmark results and compare them to a previous run if possible
Reproduction
run
npm run bench
https://stackblitz.com/edit/vitest-dev-vitest-1qwwb1?file=vite.config.ts
System Info
Used Package Manager
npm
Validations