-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for synchronous benchmarks #202
Comments
The API of the first proposal could be:
The async detection of a benchmark complete callbacks call chain could be automated (with known detection issues) The |
After more thoughts:
I guess the two last bullet points are enough to cover the need. The implementation will share common code. |
I think having explicit It seems making the API more explicit doesn't only improve reliability (if you need to run the tests synchronously, like our case, we want to avoid accidentally switching to async because someone made a change to a hook to make it async), but it also makes the implementation significantly simpler. Any concerns about app size increase? Should we expose this as |
There's difference between the 3 methods that can all have their use cases.
The existing code is already partially doing it (with known detection issues). The infrastructure allowing to detect if a suite is using async callbacks or returning promises is already here and used in
The API can enforce proper usage only if strongly typed. Meaning the enforcement will work only if TS is used. Improper usage of the sync API will still need sanity checks (even imperfect).
We can also have The code size should not increase a lot with common code sharing between implementations. |
Oh, I just saw that. I think we'd have to run all the hooks before running the benchmark to detect if they're async and switch between the modes if that's the case. I'm a bit concerned about side-effects when doing that, because we'd be running all the hooks for all the benchmark cases before running any of them. Would you be ok with just starting with |
Sure. The global API revamp discussion was just to have the big picture. Start with the part of it fulfilling your needs. |
@rubennorte do you have discord? would love to create a discord group between @jerome-benoit, you and I! |
@Aslemammad: keeping the design discussion in a github issue is fine by me. It's public and anyone can participate. |
oh yea totally, i wanted to discuss more private stuff! i'm an advocate for indexable github issues :) |
yeah, it's ruben.norte there |
Hey folks! I'm an engineer working on React Native at Meta and we're doing some explorations about benchmarking React Native internals (this isn't meant for developers using React Native, but for the people maintaining React Native itself).
We started these explorations using
tinybench
but we have some limitations requiring parts of these tests to be fully synchronous (so no async functions or promises). Would you be open to a PR to support this use case? Basically a way to callbench.run
so it runs them synchronously and returnsvoid
or the benchmark results directly, instead of a promise.In that case, do you have any preferences on how to set that up? Some options I could think of are:
runSync
method that runs synchronously and ensures none of the configuration methods return promises.run
return a promise or not based on whether any of the hooks provided promises. This feels like it could be complex to implement and it would easily switch from sync to async accidentally.If you think this is something that would be valuable for your users overall, I'd happy to submit a PR implementing it. Otherwise we can set up an internal fork for this use case, so no pressure :).
Thanks!
The text was updated successfully, but these errors were encountered: