Skip to content

Commit a19ed8a

Browse files
committed
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) ```
2 parents 1d33318 + 0431594 commit a19ed8a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libtest/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -629,19 +629,19 @@ impl<T: Write> ConsoleTestState<T> {
629629
fn fmt_thousands_sep(mut n: usize, sep: char) -> String {
630630
use std::fmt::Write;
631631
let mut output = String::new();
632-
let mut first = true;
632+
let mut trailing = false;
633633
for &pow in &[9, 6, 3, 0] {
634634
let base = 10_usize.pow(pow);
635-
if pow == 0 || n / base != 0 {
636-
if first {
635+
if pow == 0 || trailing || n / base != 0 {
636+
if !trailing {
637637
output.write_fmt(format_args!("{}", n / base)).unwrap();
638638
} else {
639639
output.write_fmt(format_args!("{:03}", n / base)).unwrap();
640640
}
641641
if pow != 0 {
642642
output.push(sep);
643643
}
644-
first = false;
644+
trailing = true;
645645
}
646646
n %= base;
647647
}

0 commit comments

Comments
 (0)