From 756c42409cc8265b2526c6d493c8c5dff429e8f6 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Fri, 14 Mar 2025 15:27:56 -0400 Subject: [PATCH] analysis-stats: always print source stats --- .../rust-analyzer/src/cli/analysis_stats.rs | 40 +++++++++---------- crates/rust-analyzer/src/cli/flags.rs | 3 -- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index 74d7913188..97a319f031 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -141,7 +141,7 @@ impl flags::AnalysisStats { workspace_loc += length; workspace_item_trees += 1; - } else if self.source_stats { + } else { let length = db.file_text(file_id).text(db).lines().count(); db.file_item_tree(EditionedFileId::current_edition(file_id).into()); @@ -155,29 +155,25 @@ impl flags::AnalysisStats { eprintln!(" item trees: {workspace_item_trees}"); let item_tree_time = item_tree_sw.elapsed(); - if self.source_stats { - eprintln!("Source stats:"); - 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!("Source stats:"); + eprintln!(" dependency lines of code: {dep_loc}, item trees: {deps_item_trees}"); + eprintln!(" workspace lines of code: {workspace_loc}, item trees: {workspace_item_trees}"); - // FIXME(salsa-transition): bring back stats for ParseQuery (file size) - // and ParseMacroExpansionQuery (mcaro expansion "file") size whenever we implement - // Salsa's memory usage tracking works with tracked functions. + // FIXME(salsa-transition): bring back stats for ParseQuery (file size) + // and ParseMacroExpansionQuery (mcaro expansion "file") size whenever we implement + // Salsa's memory usage tracking works with tracked functions. - // let mut total_file_size = Bytes::default(); - // for e in ide_db::base_db::ParseQuery.in_db(db).entries::>() { - // total_file_size += syntax_len(db.parse(e.key).syntax_node()) - // } + // let mut total_file_size = Bytes::default(); + // for e in ide_db::base_db::ParseQuery.in_db(db).entries::>() { + // total_file_size += syntax_len(db.parse(e.key).syntax_node()) + // } - // let mut total_macro_file_size = Bytes::default(); - // for e in hir::db::ParseMacroExpansionQuery.in_db(db).entries::>() { - // let val = db.parse_macro_expansion(e.key).value.0; - // total_macro_file_size += syntax_len(val.syntax_node()) - // } - // eprintln!("source files: {total_file_size}, macro files: {total_macro_file_size}"); - } + // let mut total_macro_file_size = Bytes::default(); + // for e in hir::db::ParseMacroExpansionQuery.in_db(db).entries::>() { + // let val = db.parse_macro_expansion(e.key).value.0; + // total_macro_file_size += syntax_len(val.syntax_node()) + // } + // eprintln!("source files: {total_file_size}, macro files: {total_macro_file_size}"); eprintln!("{:<20} {}", "Item Tree Collection:", item_tree_time); report_metric("item tree time", item_tree_time.time.as_millis() as u64, "ms"); @@ -261,7 +257,7 @@ impl flags::AnalysisStats { } } eprintln!( - ", mods: {}, decls: {num_decls}, bodies: {}, adts: {}, consts: {}", + ", mods: {}, decls: {num_decls}, bodies: {}, adts: {}, consts: {},", visited_modules.len(), bodies.len(), adts.len(), diff --git a/crates/rust-analyzer/src/cli/flags.rs b/crates/rust-analyzer/src/cli/flags.rs index ff24602144..13075d4994 100644 --- a/crates/rust-analyzer/src/cli/flags.rs +++ b/crates/rust-analyzer/src/cli/flags.rs @@ -62,8 +62,6 @@ xflags::xflags! { optional --randomize /// Run type inference in 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. optional -o, --only path: String @@ -231,7 +229,6 @@ pub struct AnalysisStats { pub output: Option, pub randomize: bool, pub parallel: bool, - pub source_stats: bool, pub only: Option, pub with_deps: bool, pub no_sysroot: bool,