Skip to content

Bench harness #4515

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

Merged
merged 4 commits into from
Feb 13, 2013
Merged

Bench harness #4515

merged 4 commits into from
Feb 13, 2013

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Jan 17, 2013

This is scaffolding for the new #[bench] attribute for marking unit tests as benchmarks. They are run with the --bench flag that the test runner now accepts. The runner automatically calibrates a test loop to an appropriate count to get a good per-iteration measurement.

@graydon
Copy link
Contributor Author

graydon commented Jan 18, 2013

r? @brson

@graydon
Copy link
Contributor Author

graydon commented Jan 18, 2013

Yeah, sorry, this is still pretty preliminary. You use it like this:

#[bench]
fn bench1(bh: & mut std::test::BenchHarness) {
    let mut x = 1;
    do bh.iter {
        x += 1;
        x ^= 2 * x;
    }
}

The separation is to allow you to do some scaffolding setup in the pre-iter part and then have the benchmark tool just measure the speed of the inner loop passed to .iter.

@brson
Copy link
Contributor

brson commented Jan 19, 2013

r+

I am wary about codifying this one type of test harness, instead of having an extensible system, but I don't have any concrete suggestions right now for how to get there from here, nor any grand plans to redesign std::test. Perhaps we can revisit later in the year.

@graydon
Copy link
Contributor Author

graydon commented Jan 22, 2013

Agreed. This is just to get something habitual under way. We can do mindless rewrites to a better harness if someone thinks one up.

@quentusrex
Copy link

What type of measurements is the benchharness going to be recording? Just the runtime of the iteration? For runtime can it measure real, user and system time?

@graydon
Copy link
Contributor Author

graydon commented Jan 25, 2013

No, it just measures userspace nanoseconds. Idea is to be portable and reliable -- "too easy to not-use" much like our unit test harness -- not complete or thorough. We have proper profilers for real performance tuning.

bors added a commit that referenced this pull request Feb 13, 2013
This is scaffolding for the new #[bench] attribute for marking unit tests as benchmarks. They are run with the --bench flag that the test runner now accepts. The runner automatically calibrates a test loop to an appropriate count to get a good per-iteration measurement.
@bors bors closed this Feb 13, 2013
@bors bors merged commit e5aa399 into rust-lang:incoming Feb 13, 2013
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

Successfully merging this pull request may close these issues.

4 participants