Skip to content

Commit 0f43800

Browse files
committed
Switch to markdown output
1 parent aceee88 commit 0f43800

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/librustc/util/profiling.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,27 @@ impl CategoryData {
9090
fn print(&self, lock: &mut StdoutLock) {
9191
macro_rules! p {
9292
($name:tt, $rustic_name:ident) => {
93+
let (hits, total) = self.query_counts.$rustic_name;
94+
let (hits, total) = if total > 0 {
95+
(format!("{:.2}%", (((hits as f32) / (total as f32)) * 100.0)), total.to_string())
96+
} else {
97+
("".into(), "".into())
98+
};
99+
93100
writeln!(
94101
lock,
95-
"{0: <15} \t\t {1: <15}ms",
102+
"| {0: <16} | {1: <14} | {2: <14} | {3: <8} |",
96103
$name,
97-
self.times.$rustic_name / 1_000_000
104+
self.times.$rustic_name / 1_000_000,
105+
total,
106+
hits
98107
).unwrap();
99-
100-
let (hits, total) = self.query_counts.$rustic_name;
101-
if total > 0 {
102-
writeln!(
103-
lock,
104-
"\t{} hits {} queries",
105-
hits,
106-
total
107-
).unwrap();
108-
}
109108
};
110109
}
111110

111+
writeln!(lock, "| Phase | Time (ms) | Queries | Hits (%) |").unwrap();
112+
writeln!(lock, "| ---------------- | -------------- | -------------- | -------- |").unwrap();
113+
112114
p!("Parsing", parsing);
113115
p!("Expansion", expansion);
114116
p!("TypeChecking", type_checking);
@@ -222,6 +224,7 @@ impl SelfProfiler {
222224
let crate_name = opts.crate_name.as_ref().map(|n| format!(" for {}", n)).unwrap_or_default();
223225

224226
writeln!(lock, "Self profiling results{}:", crate_name).unwrap();
227+
writeln!(lock).unwrap();
225228

226229
self.data.print(&mut lock);
227230

0 commit comments

Comments
 (0)