about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-06-18 04:52:28 +0000
committerbors <bors@rust-lang.org>2015-06-18 04:52:28 +0000
commita19ed8ad1579fa8c0a2e5477534da76be5afd3c2 (patch)
tree8d17167d0770ac788a7ffbaf61be641cda7cc5ba
parent1d33318018466a97dec2d61195e38952ca30d597 (diff)
parent04315949fb33fdce8353157a5d3dd10619bf5b37 (diff)
downloadrust-a19ed8ad1579fa8c0a2e5477534da76be5afd3c2.tar.gz
rust-a19ed8ad1579fa8c0a2e5477534da76be5afd3c2.zip
Auto merge of #26340 - bluss:bench-sigfix, r=alexcrichton
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.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 9850e0a6c2f..8f339a599b8 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;
     }