mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 12:04:43 +00:00 
			
		
		
		
	analysis-stats: always print source stats
This commit is contained in:
		
							parent
							
								
									6af729166e
								
							
						
					
					
						commit
						756c42409c
					
				
					 2 changed files with 18 additions and 25 deletions
				
			
		|  | @ -141,7 +141,7 @@ impl flags::AnalysisStats { | ||||||
| 
 | 
 | ||||||
|                             workspace_loc += length; |                             workspace_loc += length; | ||||||
|                             workspace_item_trees += 1; |                             workspace_item_trees += 1; | ||||||
|                         } else if self.source_stats { |                         } else { | ||||||
|                             let length = db.file_text(file_id).text(db).lines().count(); |                             let length = db.file_text(file_id).text(db).lines().count(); | ||||||
|                             db.file_item_tree(EditionedFileId::current_edition(file_id).into()); |                             db.file_item_tree(EditionedFileId::current_edition(file_id).into()); | ||||||
| 
 | 
 | ||||||
|  | @ -155,29 +155,25 @@ impl flags::AnalysisStats { | ||||||
|         eprintln!("  item trees: {workspace_item_trees}"); |         eprintln!("  item trees: {workspace_item_trees}"); | ||||||
|         let item_tree_time = item_tree_sw.elapsed(); |         let item_tree_time = item_tree_sw.elapsed(); | ||||||
| 
 | 
 | ||||||
|         if self.source_stats { |         eprintln!("Source stats:"); | ||||||
|             eprintln!("Source stats:"); |         eprintln!("  dependency lines of code: {dep_loc}, item trees: {deps_item_trees}"); | ||||||
|             eprintln!("  dependency lines of code: {dep_loc}, item trees: {deps_item_trees}"); |         eprintln!("  workspace lines of code: {workspace_loc}, item trees: {workspace_item_trees}"); | ||||||
|             eprintln!( |  | ||||||
|                 "  workspace lines of code: {workspace_loc}, item trees: {workspace_item_trees}" |  | ||||||
|             ); |  | ||||||
| 
 | 
 | ||||||
|             // FIXME(salsa-transition): bring back stats for ParseQuery (file size)
 |         // FIXME(salsa-transition): bring back stats for ParseQuery (file size)
 | ||||||
|             // and ParseMacroExpansionQuery (mcaro expansion "file") size whenever we implement
 |         // and ParseMacroExpansionQuery (mcaro expansion "file") size whenever we implement
 | ||||||
|             // Salsa's memory usage tracking works with tracked functions.
 |         // Salsa's memory usage tracking works with tracked functions.
 | ||||||
| 
 | 
 | ||||||
|             // let mut total_file_size = Bytes::default();
 |         // let mut total_file_size = Bytes::default();
 | ||||||
|             // for e in ide_db::base_db::ParseQuery.in_db(db).entries::<Vec<_>>() {
 |         // for e in ide_db::base_db::ParseQuery.in_db(db).entries::<Vec<_>>() {
 | ||||||
|             //     total_file_size += syntax_len(db.parse(e.key).syntax_node())
 |         //     total_file_size += syntax_len(db.parse(e.key).syntax_node())
 | ||||||
|             // }
 |         // }
 | ||||||
| 
 | 
 | ||||||
|             // let mut total_macro_file_size = Bytes::default();
 |         // let mut total_macro_file_size = Bytes::default();
 | ||||||
|             // for e in hir::db::ParseMacroExpansionQuery.in_db(db).entries::<Vec<_>>() {
 |         // for e in hir::db::ParseMacroExpansionQuery.in_db(db).entries::<Vec<_>>() {
 | ||||||
|             //     let val = db.parse_macro_expansion(e.key).value.0;
 |         //     let val = db.parse_macro_expansion(e.key).value.0;
 | ||||||
|             //     total_macro_file_size += syntax_len(val.syntax_node())
 |         //     total_macro_file_size += syntax_len(val.syntax_node())
 | ||||||
|             // }
 |         // }
 | ||||||
|             // eprintln!("source files: {total_file_size}, macro files: {total_macro_file_size}");
 |         // eprintln!("source files: {total_file_size}, macro files: {total_macro_file_size}");
 | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         eprintln!("{:<20} {}", "Item Tree Collection:", item_tree_time); |         eprintln!("{:<20} {}", "Item Tree Collection:", item_tree_time); | ||||||
|         report_metric("item tree time", item_tree_time.time.as_millis() as u64, "ms"); |         report_metric("item tree time", item_tree_time.time.as_millis() as u64, "ms"); | ||||||
|  | @ -261,7 +257,7 @@ impl flags::AnalysisStats { | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         eprintln!( |         eprintln!( | ||||||
|             ", mods: {}, decls: {num_decls}, bodies: {}, adts: {}, consts: {}", |             ", mods: {}, decls: {num_decls}, bodies: {}, adts: {}, consts: {},", | ||||||
|             visited_modules.len(), |             visited_modules.len(), | ||||||
|             bodies.len(), |             bodies.len(), | ||||||
|             adts.len(), |             adts.len(), | ||||||
|  |  | ||||||
|  | @ -62,8 +62,6 @@ xflags::xflags! { | ||||||
|             optional --randomize |             optional --randomize | ||||||
|             /// Run type inference in parallel.
 |             /// Run type inference in parallel.
 | ||||||
|             optional --parallel |             optional --parallel | ||||||
|             /// Print the total length of all source and macro files (whitespace is not counted).
 |  | ||||||
|             optional --source-stats |  | ||||||
| 
 | 
 | ||||||
|             /// Only analyze items matching this path.
 |             /// Only analyze items matching this path.
 | ||||||
|             optional -o, --only path: String |             optional -o, --only path: String | ||||||
|  | @ -231,7 +229,6 @@ pub struct AnalysisStats { | ||||||
|     pub output: Option<OutputFormat>, |     pub output: Option<OutputFormat>, | ||||||
|     pub randomize: bool, |     pub randomize: bool, | ||||||
|     pub parallel: bool, |     pub parallel: bool, | ||||||
|     pub source_stats: bool, |  | ||||||
|     pub only: Option<String>, |     pub only: Option<String>, | ||||||
|     pub with_deps: bool, |     pub with_deps: bool, | ||||||
|     pub no_sysroot: bool, |     pub no_sysroot: bool, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 David Barsky
						David Barsky