We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 1b707f7 + c7dc868 commit fb33fa4Copy full SHA for fb33fa4
src/librustc/util/profiling.rs
@@ -93,16 +93,27 @@ macro_rules! define_categories {
93
$(
94
let (hits, total) = self.query_counts.$name;
95
96
+ //normalize hits to 0%
97
+ let hit_percent =
98
+ if total > 0 {
99
+ ((hits as f32) / (total as f32)) * 100.0
100
+ } else {
101
+ 0.0
102
+ };
103
+
104
json.push_str(&format!(
105
"{{ \"category\": {}, \"time_ms\": {},
- \"query_count\": {}, \"query_hits\": {} }}",
106
+ \"query_count\": {}, \"query_hits\": {} }},",
107
stringify!($name),
108
self.times.$name / 1_000_000,
109
total,
- format!("{:.2}", (((hits as f32) / (total as f32)) * 100.0))
110
+ format!("{:.2}", hit_percent)
111
));
112
)*
113
114
+ //remove the trailing ',' character
115
+ json.pop();
116
117
json.push(']');
118
119
json
0 commit comments