Expose getBenchFn
to be able to access benchmarks functions in a custom runner
#4170
Closed
4 tasks done
Labels
Clear and concise description of the problem
I am writing a custom runner for benchmarks. I used https://github.com/vitest-dev/vitest/tree/main/packages/vitest/src/runtime/runners/benchmark.ts as a reference and got blocked when I needed to access the registered functions through
bench
.In
NodeBenchmarkRunner
's implementation, they are retrieved thanks to the following linevitest/packages/vitest/src/runtime/runners/benchmark.ts
Line 61 in edad9b1
However,
getBenchFn
is not exposed, so I cannot access it in my custom runner.Suggested solution
Export
getBenchFn
from a newvitest/bench
namespace, or somewhere else.Alternative
No response
Additional context
The equivalent
getFn
function to retrieve test functions is already exported fromvitest/suite
:vitest/packages/runner/src/index.ts
Line 4 in bdc06dc
So I think that it would make sense to export
getBenchFn
, and maybegetBenchOptions
too.I would be more than happy to submit a pull request if you accept this proposal!
For context, the custom runner would be to support
vitest
on https://codspeed.io/, I already talked about it on discord with @AslemammadP.S. Thank you for such an amazing project!
Validations
The text was updated successfully, but these errors were encountered: