Skip to content

Commit

Permalink
Include speedup in the output
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Fraux authored and BurntSushi committed May 17, 2017
1 parent d978115 commit e0f980d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/benchmark.rs
Expand Up @@ -144,11 +144,13 @@ impl Benchmark {
pub fn compare(self, new: Benchmark) -> Comparison {
let diff_ns = new.ns as i64 - self.ns as i64;
let diff_ratio = diff_ns as f64 / self.ns as f64;
let speedup = 1.0 / (1.0 + diff_ratio);
Comparison {
old: self,
new: new,
diff_ns: diff_ns,
diff_ratio: diff_ratio,
speedup: speedup,
}
}

Expand Down Expand Up @@ -176,6 +178,7 @@ pub struct Comparison {
pub new: Benchmark,
pub diff_ns: i64,
pub diff_ratio: f64,
pub speedup: f64,
}

impl Comparison {
Expand All @@ -190,6 +193,7 @@ impl Comparison {
let fst_ns = self.old.fmt_ns(variance);
let snd_ns = self.new.fmt_ns(variance);
let diff_ratio = format!("{:.2}%", self.diff_ratio * 100f64);
let speedup = format!("x {:.2}", self.speedup);
let diff_ns = {
let diff_ns = commafy(self.diff_ns.abs() as u64);
if self.diff_ns < 0 {
Expand All @@ -199,9 +203,9 @@ impl Comparison {
}
};
if regression {
row![Fr->name, Fr->fst_ns, Fr->snd_ns, rFr->diff_ns, rFr->diff_ratio]
row![Fr->name, Fr->fst_ns, Fr->snd_ns, rFr->diff_ns, rFr->diff_ratio, rFr->speedup]
} else {
row![Fg->name, Fg->fst_ns, Fg->snd_ns, rFg->diff_ns, rFg->diff_ratio]
row![Fg->name, Fg->fst_ns, Fg->snd_ns, rFg->diff_ns, rFg->diff_ratio, rFg->speedup]
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Expand Up @@ -102,7 +102,8 @@ impl Args {
b->format!("{} ns/iter", name_old),
b->format!("{} ns/iter", name_new),
br->"diff ns/iter",
br->"diff %"
br->"diff %",
br->"speedup"
]);
for c in benches.comparisons() {
let abs_per = (c.diff_ratio * 100f64).abs().trunc() as u8;
Expand Down

0 comments on commit e0f980d

Please sign in to comment.