mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Auto merge of #15070 - Veykril:analysis-stat-stuff, r=Veykril
internal: Report metric timings for file item trees and crate def map creation
This commit is contained in:
commit
bc26e81cd5
7 changed files with 67 additions and 16 deletions
|
@ -95,17 +95,41 @@ impl flags::AnalysisStats {
|
|||
eprintln!(")");
|
||||
|
||||
let mut analysis_sw = self.stop_watch();
|
||||
let mut num_crates = 0;
|
||||
let mut visited_modules = FxHashSet::default();
|
||||
let mut visit_queue = Vec::new();
|
||||
|
||||
let mut krates = Crate::all(db);
|
||||
if self.randomize {
|
||||
shuffle(&mut rng, &mut krates);
|
||||
}
|
||||
|
||||
let mut item_tree_sw = self.stop_watch();
|
||||
let mut num_item_trees = 0;
|
||||
let source_roots =
|
||||
krates.iter().cloned().map(|krate| db.file_source_root(krate.root_file(db))).unique();
|
||||
for source_root_id in source_roots {
|
||||
let source_root = db.source_root(source_root_id);
|
||||
if !source_root.is_library || self.with_deps {
|
||||
for file_id in source_root.iter() {
|
||||
if let Some(p) = source_root.path_for_file(&file_id) {
|
||||
if let Some((_, Some("rs"))) = p.name_and_extension() {
|
||||
db.file_item_tree(file_id.into());
|
||||
num_item_trees += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
eprintln!(" item trees: {num_item_trees}");
|
||||
let item_tree_time = item_tree_sw.elapsed();
|
||||
eprintln!("{:<20} {}", "Item Tree Collection:", item_tree_time);
|
||||
report_metric("item tree time", item_tree_time.time.as_millis() as u64, "ms");
|
||||
|
||||
let mut crate_def_map_sw = self.stop_watch();
|
||||
let mut num_crates = 0;
|
||||
let mut visited_modules = FxHashSet::default();
|
||||
let mut visit_queue = Vec::new();
|
||||
for krate in krates {
|
||||
let module = krate.root_module(db);
|
||||
let file_id = module.definition_source(db).file_id;
|
||||
let file_id = module.definition_source_file_id(db);
|
||||
let file_id = file_id.original_file(db);
|
||||
let source_root = db.file_source_root(file_id);
|
||||
let source_root = db.source_root(source_root);
|
||||
|
@ -171,7 +195,9 @@ impl flags::AnalysisStats {
|
|||
adts.len(),
|
||||
consts.len(),
|
||||
);
|
||||
eprintln!("{:<20} {}", "Item Collection:", analysis_sw.elapsed());
|
||||
let crate_def_map_time = crate_def_map_sw.elapsed();
|
||||
eprintln!("{:<20} {}", "Item Collection:", crate_def_map_time);
|
||||
report_metric("crate def map time", crate_def_map_time.time.as_millis() as u64, "ms");
|
||||
|
||||
if self.randomize {
|
||||
shuffle(&mut rng, &mut bodies);
|
||||
|
|
|
@ -37,14 +37,14 @@ impl flags::Diagnostics {
|
|||
let mut visited_files = FxHashSet::default();
|
||||
|
||||
let work = all_modules(db).into_iter().filter(|module| {
|
||||
let file_id = module.definition_source(db).file_id.original_file(db);
|
||||
let file_id = module.definition_source_file_id(db).original_file(db);
|
||||
let source_root = db.file_source_root(file_id);
|
||||
let source_root = db.source_root(source_root);
|
||||
!source_root.is_library
|
||||
});
|
||||
|
||||
for module in work {
|
||||
let file_id = module.definition_source(db).file_id.original_file(db);
|
||||
let file_id = module.definition_source_file_id(db).original_file(db);
|
||||
if !visited_files.contains(&file_id) {
|
||||
let crate_name =
|
||||
module.krate().display_name(db).as_deref().unwrap_or("unknown").to_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue