diff options
| author | kennytm <kennytm@gmail.com> | 2018-12-14 22:10:11 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-14 22:10:11 +0800 |
| commit | 3e17988a537a5aaa4c02d8ba586b5cfe58c73aae (patch) | |
| tree | 456d270a1c704a293883da8847b680969ca75356 | |
| parent | dadf7fcc2dc76dd90a9f5a4eea595cf7add8ffff (diff) | |
| parent | 771e8b82af5921c52f2f6074196002f8a951f596 (diff) | |
| download | rust-3e17988a537a5aaa4c02d8ba586b5cfe58c73aae.tar.gz rust-3e17988a537a5aaa4c02d8ba586b5cfe58c73aae.zip | |
Rollup merge of #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
| -rw-r--r-- | src/librustc/util/profiling.rs | 13 |
1 files changed, 9 insertions, 4 deletions
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 @@ macro_rules! define_categories { } 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 @@ macro_rules! define_categories { 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(); )* } |
