From 96bd4557d7fbda76ed3c57d40bb54c1e0330a116 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 21 Sep 2019 11:16:51 -0700 Subject: [PATCH] -Ztimings: Fix more scale problems. --- src/cargo/core/compiler/timings.js | 54 ++++++++++++++---------------- src/cargo/core/compiler/timings.rs | 13 +++---- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/cargo/core/compiler/timings.js b/src/cargo/core/compiler/timings.js index 170827363a2..28767db845c 100644 --- a/src/cargo/core/compiler/timings.js +++ b/src/cargo/core/compiler/timings.js @@ -163,9 +163,8 @@ function render_timing_graph() { for (c of CONCURRENCY_DATA) { max_v = Math.max(max_v, c.active, c.waiting, c.inactive); } - let [step, top] = split_ticks(max_v, GRAPH_HEIGHT / MIN_TICK_DIST); - let num_ticks = top / step; - let tick_dist = GRAPH_HEIGHT / num_ticks; + const px_per_v = GRAPH_HEIGHT / max_v; + const {step, tick_dist, num_ticks} = split_ticks(max_v, px_per_v, GRAPH_HEIGHT); ctx.textAlign = 'end'; for (n=0; n 100) { throw Error("tick loop too long"); } count += 1; - let top = round_up(n, step); - if (top <= max_ticks * step) { - return [step, top]; + if (max_value <= max_ticks * step) { + break; } step += 10; } } + const tick_dist = px_per_v * step; + const num_ticks = Math.floor(max_value / step); + return {step, tick_dist, num_ticks}; } function codegen_time(unit) { diff --git a/src/cargo/core/compiler/timings.rs b/src/cargo/core/compiler/timings.rs index 587bba456a5..1a3fe45052b 100644 --- a/src/cargo/core/compiler/timings.rs +++ b/src/cargo/core/compiler/timings.rs @@ -301,7 +301,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { /// Save HTML report to disk. fn report_html(&self, bcx: &BuildContext<'_, '_>) -> CargoResult<()> { - let duration = self.start.elapsed().as_secs() as u32 + 1; + let duration = d_as_f64(self.start.elapsed()); let timestamp = self.start_str.replace(&['-', ':'][..], ""); let filename = format!("cargo-timing-{}.html", timestamp); let mut f = BufWriter::new(File::create(&filename)?); @@ -314,11 +314,12 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { self.write_summary_table(&mut f, duration, bcx)?; f.write_all(HTML_CANVAS.as_bytes())?; self.write_unit_table(&mut f)?; + // It helps with pixel alignment to use whole numbers. writeln!( f, "