Skip to content
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

A note of caution on putting benchmarks inside the crate #9

Open
dralley opened this issue Oct 14, 2023 · 0 comments
Open

A note of caution on putting benchmarks inside the crate #9

dralley opened this issue Oct 14, 2023 · 0 comments

Comments

@dralley
Copy link

dralley commented Oct 14, 2023

Rust doesn't inline across crate boundaries unless you use #[inline] or LTO, whereas inside the crate it can inline anything it thinks might be worthwhile. That means that a benchmark defined inside a crate may not be getting an accurate measure of the performance that a user of the crate would see.

A practical example of this was just noticed in a library I use where the existing (libtest, not Divan) benchmarks inside the crate showed nearly twice the performance as Criterion benchmarks outside of the crate.

Therefore, while putting benchmarks inside of your crate is very convenient, it is not necessarily a good idea in all cases.

shepmaster/jetscii#57 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant