Skip to content

Commit 6a9854c

Browse files
authored
Rollup merge of rust-lang#56702 - wesleywiser:calc_total_time_stats, r=michaelwoerister
[self-profiler] Add column for percent of total time Example output: ``` Self profiling results: | Phase | Time (ms) | Time (%) | Queries | Hits (%) | ---------------- | -------------- | -------- | -------------- | -------- | Parsing | 3 | 0.52 | | | Expansion | 64 | 11.27 | | | TypeChecking | 13 | 2.36 | 35208 | 90.77 | BorrowChecking | 0 | 0.10 | 68 | 50.00 | Codegen | 22 | 3.82 | 7362 | 75.12 | Linking | 252 | 43.81 | 458 | 68.56 | Other | 219 | 38.12 | 47372 | 56.84 Optimization level: No Incremental: off ``` cc @michaelwoerister
2 parents 02d622d + 771e8b8 commit 6a9854c

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)