diff options
author | Aleksey Kladov <[email protected]> | 2021-01-11 19:17:30 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-01-11 19:17:30 +0000 |
commit | 9fd4e5c66ce3710dafde84405dc29686d0e49bf8 (patch) | |
tree | 644de14d957ca7a0f7cd265734723c11c978f20f /crates | |
parent | 3aa153b46c2519ddb584454e71d672c810edec48 (diff) |
Improve analysis stats legibility
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/cli/analysis_stats.rs | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index 30811bbbf..fd1407e60 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs | |||
@@ -58,7 +58,7 @@ impl AnalysisStatsCmd { | |||
58 | let mut db_load_sw = self.stop_watch(); | 58 | let mut db_load_sw = self.stop_watch(); |
59 | let (host, vfs) = load_cargo(&self.path, self.load_output_dirs, self.with_proc_macro)?; | 59 | let (host, vfs) = load_cargo(&self.path, self.load_output_dirs, self.with_proc_macro)?; |
60 | let db = host.raw_database(); | 60 | let db = host.raw_database(); |
61 | eprintln!("Database loaded {}", db_load_sw.elapsed()); | 61 | eprintln!("{:<20} {}", "Database loaded:", db_load_sw.elapsed()); |
62 | 62 | ||
63 | let mut analysis_sw = self.stop_watch(); | 63 | let mut analysis_sw = self.stop_watch(); |
64 | let mut num_crates = 0; | 64 | let mut num_crates = 0; |
@@ -85,7 +85,7 @@ impl AnalysisStatsCmd { | |||
85 | shuffle(&mut rng, &mut visit_queue); | 85 | shuffle(&mut rng, &mut visit_queue); |
86 | } | 86 | } |
87 | 87 | ||
88 | eprintln!("Crates in this dir: {}", num_crates); | 88 | eprint!(" crates: {}", num_crates); |
89 | let mut num_decls = 0; | 89 | let mut num_decls = 0; |
90 | let mut funcs = Vec::new(); | 90 | let mut funcs = Vec::new(); |
91 | while let Some(module) = visit_queue.pop() { | 91 | while let Some(module) = visit_queue.pop() { |
@@ -109,10 +109,8 @@ impl AnalysisStatsCmd { | |||
109 | } | 109 | } |
110 | } | 110 | } |
111 | } | 111 | } |
112 | eprintln!("Total modules found: {}", visited_modules.len()); | 112 | eprintln!(", mods: {}, decls: {}, fns: {}", visited_modules.len(), num_decls, funcs.len()); |
113 | eprintln!("Total declarations: {}", num_decls); | 113 | eprintln!("{:<20} {}", "Item Collection:", analysis_sw.elapsed()); |
114 | eprintln!("Total functions: {}", funcs.len()); | ||
115 | eprintln!("Item Collection: {}", analysis_sw.elapsed()); | ||
116 | 114 | ||
117 | if self.randomize { | 115 | if self.randomize { |
118 | shuffle(&mut rng, &mut funcs); | 116 | shuffle(&mut rng, &mut funcs); |
@@ -135,7 +133,7 @@ impl AnalysisStatsCmd { | |||
135 | snap.0.infer(f_id.into()); | 133 | snap.0.infer(f_id.into()); |
136 | }) | 134 | }) |
137 | .count(); | 135 | .count(); |
138 | eprintln!("Parallel Inference: {}", inference_sw.elapsed()); | 136 | eprintln!("{:<20} {}", "Parallel Inference:", inference_sw.elapsed()); |
139 | } | 137 | } |
140 | 138 | ||
141 | let mut inference_sw = self.stop_watch(); | 139 | let mut inference_sw = self.stop_watch(); |
@@ -273,27 +271,22 @@ impl AnalysisStatsCmd { | |||
273 | bar.inc(1); | 271 | bar.inc(1); |
274 | } | 272 | } |
275 | bar.finish_and_clear(); | 273 | bar.finish_and_clear(); |
276 | eprintln!("Total expressions: {}", num_exprs); | ||
277 | eprintln!( | 274 | eprintln!( |
278 | "Expressions of unknown type: {} ({}%)", | 275 | " exprs: {}, ??ty: {} ({}%), ?ty: {} ({}%), !ty: {}", |
276 | num_exprs, | ||
279 | num_exprs_unknown, | 277 | num_exprs_unknown, |
280 | if num_exprs > 0 { num_exprs_unknown * 100 / num_exprs } else { 100 } | 278 | percentage(num_exprs_unknown, num_exprs), |
281 | ); | ||
282 | report_metric("unknown type", num_exprs_unknown, "#"); | ||
283 | |||
284 | eprintln!( | ||
285 | "Expressions of partially unknown type: {} ({}%)", | ||
286 | num_exprs_partially_unknown, | 279 | num_exprs_partially_unknown, |
287 | if num_exprs > 0 { num_exprs_partially_unknown * 100 / num_exprs } else { 100 } | 280 | percentage(num_exprs_partially_unknown, num_exprs), |
281 | num_type_mismatches | ||
288 | ); | 282 | ); |
289 | 283 | report_metric("unknown type", num_exprs_unknown, "#"); | |
290 | eprintln!("Type mismatches: {}", num_type_mismatches); | ||
291 | report_metric("type mismatches", num_type_mismatches, "#"); | 284 | report_metric("type mismatches", num_type_mismatches, "#"); |
292 | 285 | ||
293 | eprintln!("Inference: {}", inference_sw.elapsed()); | 286 | eprintln!("{:<20} {}", "Inference:", inference_sw.elapsed()); |
294 | 287 | ||
295 | let total_span = analysis_sw.elapsed(); | 288 | let total_span = analysis_sw.elapsed(); |
296 | eprintln!("Total: {}", total_span); | 289 | eprintln!("{:<20} {}", "Total:", total_span); |
297 | report_metric("total time", total_span.time.as_millis() as u64, "ms"); | 290 | report_metric("total time", total_span.time.as_millis() as u64, "ms"); |
298 | if let Some(instructions) = total_span.instructions { | 291 | if let Some(instructions) = total_span.instructions { |
299 | report_metric("total instructions", instructions, "#instr"); | 292 | report_metric("total instructions", instructions, "#instr"); |
@@ -325,3 +318,7 @@ fn shuffle<T>(rng: &mut Rand32, slice: &mut [T]) { | |||
325 | slice.swap(0, idx); | 318 | slice.swap(0, idx); |
326 | } | 319 | } |
327 | } | 320 | } |
321 | |||
322 | fn percentage(n: u64, total: u64) -> u64 { | ||
323 | (n * 100).checked_div(total).unwrap_or(100) | ||
324 | } | ||