]> git.lizzy.rs Git - rust.git/commitdiff
[self-profiler] Add column for percent of total time
authorWesley Wiser <wwiser@gmail.com>
Tue, 11 Dec 2018 02:16:19 +0000 (21:16 -0500)
committerWesley Wiser <wwiser@gmail.com>
Tue, 11 Dec 2018 03:25:52 +0000 (22:25 -0500)
src/librustc/util/profiling.rs

index 1e648c45817332b57691a1e2942f4c744917767a..c2bfa62cf9d068737c6a5ea694fdb40778cc1d6a 100644 (file)
@@ -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();
                 )*
             }