diff options
| author | Ulrik Sverdrup <root@localhost> | 2015-06-16 13:10:27 +0200 |
|---|---|---|
| committer | Ulrik Sverdrup <root@localhost> | 2015-06-16 13:10:27 +0200 |
| commit | 04315949fb33fdce8353157a5d3dd10619bf5b37 (patch) | |
| tree | d5cf846c3a7c17865040a2894d2ec94627abe24f | |
| parent | f6341a878e46084b3afca1f331ed470fb2bd092e (diff) | |
| download | rust-04315949fb33fdce8353157a5d3dd10619bf5b37.tar.gz rust-04315949fb33fdce8353157a5d3dd10619bf5b37.zip | |
test: Fix a bug in bench result formatting
It would skip the middle part if it was 0, displaying a number a 1000 times too small. The MB/s number next to it gave it away. Fixed it looks like this: ``` test h ... bench: 1,000,129 ns/iter (+/- 4,730) ```
| -rw-r--r-- | src/libtest/lib.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 5ea843918be..a2cd7c90bf0 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -629,11 +629,11 @@ impl<T: Write> ConsoleTestState<T> { fn fmt_thousands_sep(mut n: usize, sep: char) -> String { use std::fmt::Write; let mut output = String::new(); - let mut first = true; + let mut trailing = false; for &pow in &[9, 6, 3, 0] { let base = 10_usize.pow(pow); - if pow == 0 || n / base != 0 { - if first { + if pow == 0 || trailing || n / base != 0 { + if !trailing { output.write_fmt(format_args!("{}", n / base)).unwrap(); } else { output.write_fmt(format_args!("{:03}", n / base)).unwrap(); @@ -641,7 +641,7 @@ fn fmt_thousands_sep(mut n: usize, sep: char) -> String { if pow != 0 { output.push(sep); } - first = false; + trailing = true; } n %= base; } |
