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

Example showing how to use iai_macro #5

Open
HEnquist opened this issue Jan 26, 2021 · 3 comments
Open

Example showing how to use iai_macro #5

HEnquist opened this issue Jan 26, 2021 · 3 comments

Comments

@HEnquist
Copy link

I played a bit with iai yesterday and was really impressed by the stable results. Then I also made a quick attempt to use the iai_macro but couldn't figure out what to do. Could you add a simple example?

@bheisler
Copy link
Owner

Hey, thanks for trying Iai. Good suggestion.

In the meantime, it's basically the same deal as for Criterion.rs, only use #[iai] for your benchmark functions instead of #[criterion].

@HEnquist
Copy link
Author

Got it! I had disabled the testing harness. I enabled it again and things started working just fine.

Note that for #[criterion] benchmarks, we don't need to disable the normal testing harness as we do with regular Criterion.rs benchmarks.

I read this as "it doesn't matter if you disable the normal testing harness or not". But I guess the harness is really needed.

I think just copy-pasting this: https://github.com/bheisler/iai/blob/main/macro/benches/test_macro_bench.rs
to the readme, together with the relevant bits of Cargo.toml and two lines of explanation would be enough.

@HEnquist
Copy link
Author

Please see #6

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

2 participants