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

test: Increase resolution of MB/s stat for bench runs close to 1 second #30959

Merged
merged 1 commit into from
Jan 17, 2016

Conversation

bluss
Copy link
Member

@bluss bluss commented Jan 16, 2016

test: Increase resolution of MB/s stat for bench runs close to 1 second

MB/s was based on the number of iterations performed in a second, when
the iteration duration nears 1 second (1e9 ns), the resolution of the
MB/s stat decreases.

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@bluss
Copy link
Member Author

bluss commented Jan 16, 2016

You can play with resolution like this: https://play.rust-lang.org/?gist=c56721bbd0fdfb6c090c&version=stable

https://play.rust-lang.org/?gist=10fd60f2cd7e5b2e48ac&version=stable

numbers taken from the UTF-8 fast path PR, where the benches with duration around 0.1 second and lower showed some loss of resolution in this stat.

let mb_s = (bs.bytes * iter_s) / 1_000_000;
// use iterations per 100s for better resolution in mb_s.
let iter_per_100s = 100 * 1_000_000_000 / ns_iter;
let mb_s = (bs.bytes * iter_per_100s) / 100 / 1_000_000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we simply compute

        // let mb_s = bs.bytes * (1_000_000_000 ns/s / 1_000_000 MB/B ) / ns_iter;
        let mb_s = bs.bytes * 1_000 / ns_iter;

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that seems good. I don't think we have to worry about overflow, no reason not to do this.

MB/s was based on the number of iterations performed in a second, when
the iteration duration nears 1 second (1e9 ns), the resolution of the
MB/s stat decreases.
@bluss
Copy link
Member Author

bluss commented Jan 16, 2016

Updated the commit to use @ranma42's suggestion

@Gankra
Copy link
Contributor

Gankra commented Jan 16, 2016

@bors r+

Seems legit

@bors
Copy link
Contributor

bors commented Jan 16, 2016

📌 Commit 627829b has been approved by Gankro

Manishearth added a commit to Manishearth/rust that referenced this pull request Jan 17, 2016
test: Increase resolution of MB/s stat for bench runs close to 1 second

MB/s was based on the number of iterations performed in a second, when
the iteration duration nears 1 second (1e9 ns), the resolution of the
MB/s stat decreases.
bors added a commit that referenced this pull request Jan 17, 2016
@bors bors merged commit 627829b into rust-lang:master Jan 17, 2016
@bluss bluss deleted the bench-resolution branch January 17, 2016 14:28
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.

6 participants