From: Wesley Wiser Date: Tue, 11 Dec 2018 02:16:19 +0000 (-0500) Subject: [self-profiler] Add column for percent of total time X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=771e8b82af5921c52f2f6074196002f8a951f596;p=rust.git [self-profiler] Add column for percent of total time --- diff --git a/src/librustc/util/profiling.rs b/src/librustc/util/profiling.rs index 1e648c45817..c2bfa62cf9d 100644 --- a/src/librustc/util/profiling.rs +++ b/src/librustc/util/profiling.rs @@ -62,11 +62,15 @@ fn new() -> CategoryData { } fn print(&self, lock: &mut StderrLock<'_>) { - writeln!(lock, "| Phase | Time (ms) | Queries | Hits (%) |") + writeln!(lock, "| Phase | Time (ms) \ + | Time (%) | Queries | Hits (%)") .unwrap(); - writeln!(lock, "| ---------------- | -------------- | -------------- | -------- |") + writeln!(lock, "| ---------------- | -------------- \ + | -------- | -------------- | --------") .unwrap(); + let total_time = ($(self.times.$name + )* 0) as f32; + $( let (hits, total) = self.query_counts.$name; let (hits, total) = if total > 0 { @@ -78,11 +82,12 @@ fn print(&self, lock: &mut StderrLock<'_>) { writeln!( lock, - "| {0: <16} | {1: <14} | {2: <14} | {3: <8} |", + "| {0: <16} | {1: <14} | {2: <8.2} | {3: <14} | {4: <8}", stringify!($name), self.times.$name / 1_000_000, + ((self.times.$name as f32) / total_time) * 100.0, total, - hits + hits, ).unwrap(); )* }