Skip to content

test: Display benchmark results with thousands separators #26068

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 1 commit into from
Jun 9, 2015

Conversation

bluss
Copy link
Member

@bluss bluss commented Jun 7, 2015

test: Display benchmark results with thousands separators

Example display:

running 9 tests
test a ... bench:           0 ns/iter (+/- 0)
test b ... bench:          52 ns/iter (+/- 0)
test c ... bench:          88 ns/iter (+/- 0)
test d ... bench:         618 ns/iter (+/- 111)
test e ... bench:       5,933 ns/iter (+/- 87)
test f ... bench:      59,280 ns/iter (+/- 1,052)
test g ... bench:     588,672 ns/iter (+/- 3,381)
test h ... bench:   5,894,227 ns/iter (+/- 303,489)
test i ... bench:  59,112,382 ns/iter (+/- 1,500,110)

Fixes #10953
Fixes #26109

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@bluss
Copy link
Member Author

bluss commented Jun 7, 2015

r? @huonw

I think scientific notation is too hard to read. The nicest improvement is rounding to sig figs, units are a bit tricky to notice too.

@rust-highfive rust-highfive assigned huonw and unassigned brson Jun 7, 2015
@bluss
Copy link
Member Author

bluss commented Jun 8, 2015

Maybe four sigfigs & 1 sigfig deviation is better

example

running 9 tests
test a ... bench:         0 ns/iter (+/- 0)
test b ... bench:        52 ns/iter (+/- 0)
test c ... bench:        87 ns/iter (+/- 0)
test d ... bench:       617 ns/iter (+/- 1)
test e ... bench:     5.913 us/iter (+/- 0.02)
test f ... bench:     58.87 us/iter (+/- 0.03)
test g ... bench:     588.7 us/iter (+/- 0.7)
test h ... bench:     5.885 ms/iter (+/- 0.03)
test i ... bench:     58.88 ms/iter (+/- 0.2)

Example from real benchmarks

running 10 tests
test slice_iter              ... bench:        24 ns/iter (+/- 2)
test slice_iter_rev          ... bench:        24 ns/iter (+/- 0)
test stride_iter             ... bench:        24 ns/iter (+/- 1)
test stride_iter_rev         ... bench:        24 ns/iter (+/- 0)
test zip_loop                ... bench:       923 ns/iter (+/- 53)
test zip_loop3               ... bench:     1.372 us/iter (+/- 0.1)
test zip_slices_default_zip  ... bench:       935 ns/iter (+/- 9)
test zip_slices_default_zip3 ... bench:     1.383 us/iter (+/- 0.08)
test zip_slices_ziptuple     ... bench:       941 ns/iter (+/- 40)
test zipslices               ... bench:       942 ns/iter (+/- 167)

test result: ok. 0 passed; 0 failed; 0 ignored; 10 measured

@huonw
Copy link
Member

huonw commented Jun 8, 2015

Hm, as you say, the distinction between units is very subtle, especially the two most common unfortunately (n vs. u).

@Gankra
Copy link
Contributor

Gankra commented Jun 8, 2015

More than anything it seems harder to "follow the trend" visually. Actual
charts and diagrams seems like a richer way to handle this sort of thing.

On Mon, Jun 8, 2015 at 3:37 PM, Huon Wilson notifications@github.com
wrote:

Hm, as you say, the distinction between units is very subtle, especially
the two most common unfortunately (n vs. u).


Reply to this email directly or view it on GitHub
#26068 (comment).

@bluss
Copy link
Member Author

bluss commented Jun 8, 2015

Let's do thousands separators instead?

@huonw
Copy link
Member

huonw commented Jun 8, 2015

That might be better yeah.

@bluss
Copy link
Member Author

bluss commented Jun 8, 2015

They look like this

running 9 tests
test a ... bench:           0 ns/iter (+/- 0)
test b ... bench:          52 ns/iter (+/- 0)
test c ... bench:          88 ns/iter (+/- 0)
test d ... bench:         618 ns/iter (+/- 111)
test e ... bench:       5,933 ns/iter (+/- 87)
test f ... bench:      59,280 ns/iter (+/- 1,052)
test g ... bench:     588,672 ns/iter (+/- 3,381)
test h ... bench:   5,894,227 ns/iter (+/- 303,489)
test i ... bench:  59,112,382 ns/iter (+/- 1,500,110)

test result: ok. 0 passed; 0 failed; 0 ignored; 9 measured

I think that's good enough. We could round it, but more correct was already harder to read.

@bluss
Copy link
Member Author

bluss commented Jun 8, 2015

Updated branch. I guess the thousands formatting was pretty quick and dirty.

@bluss bluss changed the title test: Display benchmark results rounded to significant figures test: Display benchmark results with thousands separators Jun 8, 2015
let base = 10_usize.pow(pow);
if pow == 0 || n / base != 0 {
if first {
output.write_fmt(format_args!("{}", n / base)).ok();
Copy link
Member

Choose a reason for hiding this comment

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

ok -> unwrap()?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess that's more idiomatic. On a string it doesn't matter.

Example display:

```
running 9 tests
test a ... bench:           0 ns/iter (+/- 0)
test b ... bench:          52 ns/iter (+/- 0)
test c ... bench:          88 ns/iter (+/- 0)
test d ... bench:         618 ns/iter (+/- 111)
test e ... bench:       5,933 ns/iter (+/- 87)
test f ... bench:      59,280 ns/iter (+/- 1,052)
test g ... bench:     588,672 ns/iter (+/- 3,381)
test h ... bench:   5,894,227 ns/iter (+/- 303,489)
test i ... bench:  59,112,382 ns/iter (+/- 1,500,110)
```

Fixes rust-lang#10953
Fixes rust-lang#26109
@bluss
Copy link
Member Author

bluss commented Jun 9, 2015

Updated to use .unwrap().

@huonw
Copy link
Member

huonw commented Jun 9, 2015

@bors r+

(Now there's just the question of localising it properly...)

@bors
Copy link
Collaborator

bors commented Jun 9, 2015

📌 Commit 2b50c15 has been approved by huonw

@bors
Copy link
Collaborator

bors commented Jun 9, 2015

⌛ Testing commit 2b50c15 with merge f1313da...

@bors
Copy link
Collaborator

bors commented Jun 9, 2015

💔 Test failed - auto-mac-64-opt

@alexcrichton
Copy link
Member

@bors: retry

On Mon, Jun 8, 2015 at 9:28 PM, bors notifications@github.com wrote:

[image: 💔] Test failed - auto-mac-64-opt
http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5266


Reply to this email directly or view it on GitHub
#26068 (comment).

@bors
Copy link
Collaborator

bors commented Jun 9, 2015

⌛ Testing commit 2b50c15 with merge a9f50bd...

bors added a commit that referenced this pull request Jun 9, 2015
test: Display benchmark results with thousands separators

Example display:

```
running 9 tests
test a ... bench:           0 ns/iter (+/- 0)
test b ... bench:          52 ns/iter (+/- 0)
test c ... bench:          88 ns/iter (+/- 0)
test d ... bench:         618 ns/iter (+/- 111)
test e ... bench:       5,933 ns/iter (+/- 87)
test f ... bench:      59,280 ns/iter (+/- 1,052)
test g ... bench:     588,672 ns/iter (+/- 3,381)
test h ... bench:   5,894,227 ns/iter (+/- 303,489)
test i ... bench:  59,112,382 ns/iter (+/- 1,500,110)
```

Fixes #10953
Fixes #26109
@bors bors merged commit 2b50c15 into rust-lang:master Jun 9, 2015
@bluss bluss deleted the bench-sigfigs branch June 9, 2015 10:56
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.

7 participants