@@ -9,10 +9,11 @@ use std::{
99
1010use hir:: {
1111 db:: { AstDatabase , DefDatabase , HirDatabase } ,
12- AssocItem , Crate , HasSource , HirDisplay , ModuleDef ,
12+ AssocItem , Crate , Function , HasSource , HirDisplay , ModuleDef ,
1313} ;
1414use hir_def:: FunctionId ;
1515use hir_ty:: TypeWalk ;
16+ use ide:: { AnalysisHost , RootDatabase } ;
1617use ide_db:: base_db:: {
1718 salsa:: { self , ParallelDatabase } ,
1819 SourceDatabaseExt ,
@@ -24,6 +25,7 @@ use rayon::prelude::*;
2425use rustc_hash:: FxHashSet ;
2526use stdx:: format_to;
2627use syntax:: AstNode ;
28+ use vfs:: Vfs ;
2729
2830use crate :: cli:: {
2931 load_cargo:: { load_workspace_at, LoadCargoConfig } ,
@@ -51,6 +53,7 @@ pub struct AnalysisStatsCmd {
5153 pub path : PathBuf ,
5254 pub load_output_dirs : bool ,
5355 pub with_proc_macro : bool ,
56+ pub skip_inference : bool ,
5457}
5558
5659impl AnalysisStatsCmd {
@@ -128,6 +131,39 @@ impl AnalysisStatsCmd {
128131 shuffle ( & mut rng, & mut funcs) ;
129132 }
130133
134+ if !self . skip_inference {
135+ self . run_inference ( & host, db, & vfs, & funcs, verbosity) ;
136+ }
137+
138+ let total_span = analysis_sw. elapsed ( ) ;
139+ eprintln ! ( "{:<20} {}" , "Total:" , total_span) ;
140+ report_metric ( "total time" , total_span. time . as_millis ( ) as u64 , "ms" ) ;
141+ if let Some ( instructions) = total_span. instructions {
142+ report_metric ( "total instructions" , instructions, "#instr" ) ;
143+ }
144+ if let Some ( memory) = total_span. memory {
145+ report_metric ( "total memory" , memory. allocated . megabytes ( ) as u64 , "MB" ) ;
146+ }
147+
148+ if env:: var ( "RA_COUNT" ) . is_ok ( ) {
149+ eprintln ! ( "{}" , profile:: countme:: get_all( ) ) ;
150+ }
151+
152+ if self . memory_usage && verbosity. is_verbose ( ) {
153+ print_memory_usage ( host, vfs) ;
154+ }
155+
156+ Ok ( ( ) )
157+ }
158+
159+ fn run_inference (
160+ & self ,
161+ host : & AnalysisHost ,
162+ db : & RootDatabase ,
163+ vfs : & Vfs ,
164+ funcs : & [ Function ] ,
165+ verbosity : Verbosity ,
166+ ) {
131167 let mut bar = match verbosity {
132168 Verbosity :: Quiet | Verbosity :: Spammy => ProgressReport :: hidden ( ) ,
133169 _ if self . parallel => ProgressReport :: hidden ( ) ,
@@ -154,7 +190,7 @@ impl AnalysisStatsCmd {
154190 let mut num_exprs_unknown = 0 ;
155191 let mut num_exprs_partially_unknown = 0 ;
156192 let mut num_type_mismatches = 0 ;
157- for f in funcs {
193+ for f in funcs. iter ( ) . copied ( ) {
158194 let name = f. name ( db) ;
159195 let full_name = f
160196 . module ( db)
@@ -296,26 +332,6 @@ impl AnalysisStatsCmd {
296332 report_metric ( "type mismatches" , num_type_mismatches, "#" ) ;
297333
298334 eprintln ! ( "{:<20} {}" , "Inference:" , inference_sw. elapsed( ) ) ;
299-
300- let total_span = analysis_sw. elapsed ( ) ;
301- eprintln ! ( "{:<20} {}" , "Total:" , total_span) ;
302- report_metric ( "total time" , total_span. time . as_millis ( ) as u64 , "ms" ) ;
303- if let Some ( instructions) = total_span. instructions {
304- report_metric ( "total instructions" , instructions, "#instr" ) ;
305- }
306- if let Some ( memory) = total_span. memory {
307- report_metric ( "total memory" , memory. allocated . megabytes ( ) as u64 , "MB" ) ;
308- }
309-
310- if env:: var ( "RA_COUNT" ) . is_ok ( ) {
311- eprintln ! ( "{}" , profile:: countme:: get_all( ) ) ;
312- }
313-
314- if self . memory_usage && verbosity. is_verbose ( ) {
315- print_memory_usage ( host, vfs) ;
316- }
317-
318- Ok ( ( ) )
319335 }
320336
321337 fn stop_watch ( & self ) -> StopWatch {
0 commit comments