diff options
| author | Wesley Wiser <wwiser@gmail.com> | 2018-06-11 23:41:11 -0400 |
|---|---|---|
| committer | Wesley Wiser <wwiser@gmail.com> | 2018-08-02 18:57:24 -0400 |
| commit | 4552607d64669335e12cb4c69e02a759668cba22 (patch) | |
| tree | fa8ba7ffe8a5b8e1467cf564701bf60e593c68e1 | |
| parent | 51cc594e106ab5c0452784e543b56d5a0b42cfe7 (diff) | |
| download | rust-4552607d64669335e12cb4c69e02a759668cba22.tar.gz rust-4552607d64669335e12cb4c69e02a759668cba22.zip | |
Refactor json printing
| -rw-r--r-- | src/librustc/util/profiling.rs | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/src/librustc/util/profiling.rs b/src/librustc/util/profiling.rs index 73604d2a437..b32122aad85 100644 --- a/src/librustc/util/profiling.rs +++ b/src/librustc/util/profiling.rs @@ -122,43 +122,29 @@ impl CategoryData { } fn json(&self) -> String { + macro_rules! j { + ($category:tt, $rustic_name:ident) => { + format!("{{ \"category\": {}, \"time_ms\": {} }}", stringify!($category), self.times.$rustic_name / 1_000_000) + } + } + format!("[ - {{ - \"category\": \"Parsing\", - \"time_ms\": {} - }}, - {{ - \"category\": \"Expansion\", - \"time_ms\": {} - }}, - {{ - \"category\": \"TypeChecking\", - \"time_ms\": {} - }}, - {{ - \"category\": \"BorrowChecking\", - \"time_ms\": {} - }}, - {{ - \"category\": \"Codegen\", - \"time_ms\": {} - }}, - {{ - \"category\": \"Linking\", - \"time_ms\": {} - }}, - {{ - \"category\": \"Other\", - \"time_ms\": {} - }} + {}, + {}, + {}, + {}, + {}, + {}, + {} ]", - self.times.parsing / 1_000_000, - self.times.expansion / 1_000_000, - self.times.type_checking / 1_000_000, - self.times.borrow_checking / 1_000_000, - self.times.codegen / 1_000_000, - self.times.linking / 1_000_000, - self.times.other / 1_000_000) + j!("Parsing", parsing), + j!("Expansion", expansion), + j!("TypeChecking", type_checking), + j!("BorrowChecking", borrow_checking), + j!("Codegen", codegen), + j!("Linking", linking), + j!("Other", other) + ) } } |
