Skip to content

Commit 771e8b8

Browse files
committed
[self-profiler] Add column for percent of total time
1 parent da1527c commit 771e8b8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/librustc/util/profiling.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ macro_rules! define_categories {
6262
}
6363

6464
fn print(&self, lock: &mut StderrLock<'_>) {
65-
writeln!(lock, "| Phase | Time (ms) | Queries | Hits (%) |")
65+
writeln!(lock, "| Phase | Time (ms) \
66+
| Time (%) | Queries | Hits (%)")
6667
.unwrap();
67-
writeln!(lock, "| ---------------- | -------------- | -------------- | -------- |")
68+
writeln!(lock, "| ---------------- | -------------- \
69+
| -------- | -------------- | --------")
6870
.unwrap();
6971

72+
let total_time = ($(self.times.$name + )* 0) as f32;
73+
7074
$(
7175
let (hits, total) = self.query_counts.$name;
7276
let (hits, total) = if total > 0 {
@@ -78,11 +82,12 @@ macro_rules! define_categories {
7882

7983
writeln!(
8084
lock,
81-
"| {0: <16} | {1: <14} | {2: <14} | {3: <8} |",
85+
"| {0: <16} | {1: <14} | {2: <8.2} | {3: <14} | {4: <8}",
8286
stringify!($name),
8387
self.times.$name / 1_000_000,
88+
((self.times.$name as f32) / total_time) * 100.0,
8489
total,
85-
hits
90+
hits,
8691
).unwrap();
8792
)*
8893
}

0 commit comments

Comments
 (0)