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

Introduce rune bench for running micro benchmarks #296

Merged
merged 3 commits into from
Nov 9, 2021
Merged

Introduce rune bench for running micro benchmarks #296

merged 3 commits into from
Nov 9, 2021

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented Nov 8, 2021

This allows for specifying benchmark functions with the #[bench] attribute, which uses a similar contract as the same attribute in Rust.

#[bench]
fn bench_try(b) {
    b.iter(|| {
        Ok(Ok(Ok(Ok(Ok(Ok(42))))))??????
    });
}

This can be run with the new bench subcommand. It's currently very simple and only reports average and standard deviation after performing a number of warmups and iterations. I expect this to be improved at a later point.

> cargo run --release --bin rune -- bench scripts\benches.rn
Found 1 benches...
bench bench_try#0: mean=780.00ns, stddev=50.99, iterations=100

I've re-used some of the plumbing introduced with the #[test] attribute in 4b4683a.

@udoprog udoprog requested a review from tgolsson November 8, 2021 23:06
@udoprog udoprog force-pushed the bench branch 2 times, most recently from bad73ba to fff027b Compare November 8, 2021 23:33
@udoprog udoprog added the enhancement New feature or request label Nov 8, 2021
@udoprog udoprog merged commit e368fa9 into main Nov 9, 2021
@udoprog udoprog deleted the bench branch November 9, 2021 15:54
@udoprog udoprog added the changelog Issue has been added to the changelog label Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Issue has been added to the changelog enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant