Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@waynevanson
Copy link

@waynevanson waynevanson commented Feb 23, 2025

Description

  1. This PR allows hooks to be used when running vitest bench.
  2. This is essentially an updated fork of feat(vitest): support hooks in bench runner #5076.
  3. Closes Support hooks in bench API #5075.
  4. Creating this as we'd like to use hooks in benchmarks in test(bench): add benchmarking ariakit/ariakit#4415

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Feb 23, 2025

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit e621d3a
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/67bacc987853ef00086925b2
😎 Deploy Preview https://deploy-preview-7541--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@waynevanson waynevanson changed the title feat(bench): add hooks in bench mode feat: add hooks in bench mode Apr 15, 2025
@waynevanson waynevanson marked this pull request as ready for review April 16, 2025 01:47
@waynevanson
Copy link
Author

I spoke with a team member in the Discord and they mentioned that windows tests are flaky, even in main. That's why it's marked as ready for review.

@hi-ogawa hi-ogawa moved this to P2 - 2 in Team Board Apr 17, 2025
@hi-ogawa hi-ogawa added the p2-to-be-discussed Enhancement under consideration (priority) label Apr 17, 2025
@erunion
Copy link

erunion commented Jun 5, 2025

Is this still in limbo with flaky Windows tests? My team is chomping at the bit to start using this. 🥺

@waynevanson
Copy link
Author

Is this still in limbo with flaky Windows tests? My team is chomping at the bit to start using this. 🥺

I'll update the branch and see if there are still issues.

@arv
Copy link

arv commented Jun 9, 2025

Just to be clear, is this unrelated to https://tinylibs.github.io/tinybench/interfaces/FnOptions.html#beforeeach and https://tinylibs.github.io/tinybench/interfaces/FnOptions.html#aftereach which allows running code in every iteration that is not included in the total time?

The FnOptions are crucial to allow measuring anything that has a large setup time like setting up a db or a file system before each iteration.

@waynevanson
Copy link
Author

Just to be clear, is this unrelated to https://tinylibs.github.io/tinybench/interfaces/FnOptions.html#beforeeach and https://tinylibs.github.io/tinybench/interfaces/FnOptions.html#aftereach which allows running code in every iteration that is not included in the total time?

The FnOptions are crucial to allow measuring anything that has a large setup time like setting up a db or a file system before each iteration.

So you're concerned that the current implementation of our Vitest hooks will are part of the execution time? I think it would in it's current state and I don't believe it's what is intended. I can fix.

@arv
Copy link

arv commented Jun 16, 2025

So you're concerned that the current implementation of our Vitest hooks will are part of the execution time? I think it would in it's current state and I don't believe it's what is intended. I can fix.

I was actually more concerned that we are not exposing the tinybench setup/teardown and how they can be exposed in a consistent manner to vitest bench tasks.

@waynevanson
Copy link
Author

So you're concerned that the current implementation of our Vitest hooks will are part of the execution time? I think it would in it's current state and I don't believe it's what is intended. I can fix.

I was actually more concerned that we are not exposing the tinybench setup/teardown and how they can be exposed in a consistent manner to vitest bench tasks.

@arv They're already exposed I believe, as the second parameter in a Vitest benchmark. Just forwards the object to TinyBench.

Do you have a recommendation of how you'd imagine they should be exposed?

@sheremet-va sheremet-va moved this from P2 - 2 to Rejected in Team Board Jul 18, 2025
@waynevanson
Copy link
Author

Benchmarks being reimagined - I'll close this.

@waynevanson waynevanson deleted the feat.bench-hooks branch November 24, 2025 10:31
@arv
Copy link

arv commented Nov 26, 2025

@waynevanson is there a PR/issue I can follow?

@waynevanson
Copy link
Author

Yes @arv, github.com//discussions/7850

I've also created this package to run tests as benchmarks which is currently in development.
https://github.com/waynevanson/vitest-runner-benchmark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-to-be-discussed Enhancement under consideration (priority)

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Support hooks in bench API

4 participants