@@ -90,25 +90,27 @@ impl CategoryData {
90
90
fn print ( & self , lock : & mut StdoutLock ) {
91
91
macro_rules! p {
92
92
( $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
+
93
100
writeln!(
94
101
lock,
95
- "{0: <15} \t \t {1: <15}ms " ,
102
+ "| {0: <16} | {1: <14} | {2: <14} | {3: <8} | " ,
96
103
$name,
97
- self . times. $rustic_name / 1_000_000
104
+ self . times. $rustic_name / 1_000_000 ,
105
+ total,
106
+ hits
98
107
) . 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
- }
109
108
} ;
110
109
}
111
110
111
+ writeln ! ( lock, "| Phase | Time (ms) | Queries | Hits (%) |" ) . unwrap ( ) ;
112
+ writeln ! ( lock, "| ---------------- | -------------- | -------------- | -------- |" ) . unwrap ( ) ;
113
+
112
114
p ! ( "Parsing" , parsing) ;
113
115
p ! ( "Expansion" , expansion) ;
114
116
p ! ( "TypeChecking" , type_checking) ;
@@ -222,6 +224,7 @@ impl SelfProfiler {
222
224
let crate_name = opts. crate_name . as_ref ( ) . map ( |n| format ! ( " for {}" , n) ) . unwrap_or_default ( ) ;
223
225
224
226
writeln ! ( lock, "Self profiling results{}:" , crate_name) . unwrap ( ) ;
227
+ writeln ! ( lock) . unwrap ( ) ;
225
228
226
229
self . data . print ( & mut lock) ;
227
230
0 commit comments