@@ -9,10 +9,11 @@ use std::{
9
9
10
10
use hir:: {
11
11
db:: { AstDatabase , DefDatabase , HirDatabase } ,
12
- AssocItem , Crate , HasSource , HirDisplay , ModuleDef ,
12
+ AssocItem , Crate , Function , HasSource , HirDisplay , ModuleDef ,
13
13
} ;
14
14
use hir_def:: FunctionId ;
15
15
use hir_ty:: TypeWalk ;
16
+ use ide:: { AnalysisHost , RootDatabase } ;
16
17
use ide_db:: base_db:: {
17
18
salsa:: { self , ParallelDatabase } ,
18
19
SourceDatabaseExt ,
@@ -24,6 +25,7 @@ use rayon::prelude::*;
24
25
use rustc_hash:: FxHashSet ;
25
26
use stdx:: format_to;
26
27
use syntax:: AstNode ;
28
+ use vfs:: Vfs ;
27
29
28
30
use crate :: cli:: {
29
31
load_cargo:: { load_workspace_at, LoadCargoConfig } ,
@@ -51,6 +53,7 @@ pub struct AnalysisStatsCmd {
51
53
pub path : PathBuf ,
52
54
pub load_output_dirs : bool ,
53
55
pub with_proc_macro : bool ,
56
+ pub skip_inference : bool ,
54
57
}
55
58
56
59
impl AnalysisStatsCmd {
@@ -128,6 +131,39 @@ impl AnalysisStatsCmd {
128
131
shuffle ( & mut rng, & mut funcs) ;
129
132
}
130
133
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
+ ) {
131
167
let mut bar = match verbosity {
132
168
Verbosity :: Quiet | Verbosity :: Spammy => ProgressReport :: hidden ( ) ,
133
169
_ if self . parallel => ProgressReport :: hidden ( ) ,
@@ -154,7 +190,7 @@ impl AnalysisStatsCmd {
154
190
let mut num_exprs_unknown = 0 ;
155
191
let mut num_exprs_partially_unknown = 0 ;
156
192
let mut num_type_mismatches = 0 ;
157
- for f in funcs {
193
+ for f in funcs. iter ( ) . copied ( ) {
158
194
let name = f. name ( db) ;
159
195
let full_name = f
160
196
. module ( db)
@@ -296,26 +332,6 @@ impl AnalysisStatsCmd {
296
332
report_metric ( "type mismatches" , num_type_mismatches, "#" ) ;
297
333
298
334
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 ( ( ) )
319
335
}
320
336
321
337
fn stop_watch ( & self ) -> StopWatch {
0 commit comments