mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Merge pull request #20560 from ChayimFriedman2/analysis-stats-improve
fix: Add progress bars to more places in analysis-stats
This commit is contained in:
commit
dd7c7ae44c
@ -333,7 +333,7 @@ impl flags::AnalysisStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.run_all_ide_things {
|
if self.run_all_ide_things {
|
||||||
self.run_ide_things(host.analysis(), file_ids.clone());
|
self.run_ide_things(host.analysis(), file_ids.clone(), db, &vfs, verbosity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.run_term_search {
|
if self.run_term_search {
|
||||||
@ -393,15 +393,27 @@ impl flags::AnalysisStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_const_eval(&self, db: &RootDatabase, bodies: &[DefWithBody], verbosity: Verbosity) {
|
fn run_const_eval(&self, db: &RootDatabase, bodies: &[DefWithBody], verbosity: Verbosity) {
|
||||||
|
let len = bodies
|
||||||
|
.iter()
|
||||||
|
.filter(|body| matches!(body, DefWithBody::Const(_) | DefWithBody::Static(_)))
|
||||||
|
.count();
|
||||||
|
let mut bar = match verbosity {
|
||||||
|
Verbosity::Quiet | Verbosity::Spammy => ProgressReport::hidden(),
|
||||||
|
_ if self.parallel || self.output.is_some() => ProgressReport::hidden(),
|
||||||
|
_ => ProgressReport::new(len),
|
||||||
|
};
|
||||||
|
|
||||||
let mut sw = self.stop_watch();
|
let mut sw = self.stop_watch();
|
||||||
let mut all = 0;
|
let mut all = 0;
|
||||||
let mut fail = 0;
|
let mut fail = 0;
|
||||||
for &b in bodies {
|
for &b in bodies {
|
||||||
|
bar.set_message(move || format!("const eval: {}", full_name(db, b, b.module(db))));
|
||||||
let res = match b {
|
let res = match b {
|
||||||
DefWithBody::Const(c) => c.eval(db),
|
DefWithBody::Const(c) => c.eval(db),
|
||||||
DefWithBody::Static(s) => s.eval(db),
|
DefWithBody::Static(s) => s.eval(db),
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
|
bar.inc(1);
|
||||||
all += 1;
|
all += 1;
|
||||||
let Err(error) = res else {
|
let Err(error) = res else {
|
||||||
continue;
|
continue;
|
||||||
@ -409,10 +421,11 @@ impl flags::AnalysisStats {
|
|||||||
if verbosity.is_spammy() {
|
if verbosity.is_spammy() {
|
||||||
let full_name =
|
let full_name =
|
||||||
full_name_of_item(db, b.module(db), b.name(db).unwrap_or(Name::missing()));
|
full_name_of_item(db, b.module(db), b.name(db).unwrap_or(Name::missing()));
|
||||||
println!("Const eval for {full_name} failed due {error:?}");
|
bar.println(format!("Const eval for {full_name} failed due {error:?}"));
|
||||||
}
|
}
|
||||||
fail += 1;
|
fail += 1;
|
||||||
}
|
}
|
||||||
|
bar.finish_and_clear();
|
||||||
let const_eval_time = sw.elapsed();
|
let const_eval_time = sw.elapsed();
|
||||||
eprintln!("{:<20} {}", "Const evaluation:", const_eval_time);
|
eprintln!("{:<20} {}", "Const evaluation:", const_eval_time);
|
||||||
eprintln!("Failed const evals: {fail} ({}%)", percentage(fail, all));
|
eprintln!("Failed const evals: {fail} ({}%)", percentage(fail, all));
|
||||||
@ -662,6 +675,10 @@ impl flags::AnalysisStats {
|
|||||||
let mut all = 0;
|
let mut all = 0;
|
||||||
let mut fail = 0;
|
let mut fail = 0;
|
||||||
for &body_id in bodies {
|
for &body_id in bodies {
|
||||||
|
bar.set_message(move || {
|
||||||
|
format!("mir lowering: {}", full_name(db, body_id, body_id.module(db)))
|
||||||
|
});
|
||||||
|
bar.inc(1);
|
||||||
if matches!(body_id, DefWithBody::Variant(_)) {
|
if matches!(body_id, DefWithBody::Variant(_)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1089,12 +1106,29 @@ impl flags::AnalysisStats {
|
|||||||
report_metric("body lowering time", body_lowering_time.time.as_millis() as u64, "ms");
|
report_metric("body lowering time", body_lowering_time.time.as_millis() as u64, "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_ide_things(&self, analysis: Analysis, mut file_ids: Vec<EditionedFileId>) {
|
fn run_ide_things(
|
||||||
|
&self,
|
||||||
|
analysis: Analysis,
|
||||||
|
mut file_ids: Vec<EditionedFileId>,
|
||||||
|
db: &RootDatabase,
|
||||||
|
vfs: &Vfs,
|
||||||
|
verbosity: Verbosity,
|
||||||
|
) {
|
||||||
|
let len = file_ids.len();
|
||||||
|
let create_bar = || match verbosity {
|
||||||
|
Verbosity::Quiet | Verbosity::Spammy => ProgressReport::hidden(),
|
||||||
|
_ if self.parallel || self.output.is_some() => ProgressReport::hidden(),
|
||||||
|
_ => ProgressReport::new(len),
|
||||||
|
};
|
||||||
|
|
||||||
file_ids.sort();
|
file_ids.sort();
|
||||||
file_ids.dedup();
|
file_ids.dedup();
|
||||||
let mut sw = self.stop_watch();
|
let mut sw = self.stop_watch();
|
||||||
|
|
||||||
|
let mut bar = create_bar();
|
||||||
for &file_id in &file_ids {
|
for &file_id in &file_ids {
|
||||||
|
let msg = format!("diagnostics: {}", vfs.file_path(file_id.file_id(db)));
|
||||||
|
bar.set_message(move || msg.clone());
|
||||||
_ = analysis.full_diagnostics(
|
_ = analysis.full_diagnostics(
|
||||||
&DiagnosticsConfig {
|
&DiagnosticsConfig {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@ -1121,8 +1155,14 @@ impl flags::AnalysisStats {
|
|||||||
ide::AssistResolveStrategy::All,
|
ide::AssistResolveStrategy::All,
|
||||||
analysis.editioned_file_id_to_vfs(file_id),
|
analysis.editioned_file_id_to_vfs(file_id),
|
||||||
);
|
);
|
||||||
|
bar.inc(1);
|
||||||
}
|
}
|
||||||
|
bar.finish_and_clear();
|
||||||
|
|
||||||
|
let mut bar = create_bar();
|
||||||
for &file_id in &file_ids {
|
for &file_id in &file_ids {
|
||||||
|
let msg = format!("inlay hints: {}", vfs.file_path(file_id.file_id(db)));
|
||||||
|
bar.set_message(move || msg.clone());
|
||||||
_ = analysis.inlay_hints(
|
_ = analysis.inlay_hints(
|
||||||
&InlayHintsConfig {
|
&InlayHintsConfig {
|
||||||
render_colons: false,
|
render_colons: false,
|
||||||
@ -1158,8 +1198,14 @@ impl flags::AnalysisStats {
|
|||||||
analysis.editioned_file_id_to_vfs(file_id),
|
analysis.editioned_file_id_to_vfs(file_id),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
bar.inc(1);
|
||||||
}
|
}
|
||||||
|
bar.finish_and_clear();
|
||||||
|
|
||||||
|
let mut bar = create_bar();
|
||||||
for &file_id in &file_ids {
|
for &file_id in &file_ids {
|
||||||
|
let msg = format!("annotations: {}", vfs.file_path(file_id.file_id(db)));
|
||||||
|
bar.set_message(move || msg.clone());
|
||||||
analysis
|
analysis
|
||||||
.annotations(
|
.annotations(
|
||||||
&AnnotationConfig {
|
&AnnotationConfig {
|
||||||
@ -1178,7 +1224,10 @@ impl flags::AnalysisStats {
|
|||||||
.for_each(|annotation| {
|
.for_each(|annotation| {
|
||||||
_ = analysis.resolve_annotation(annotation);
|
_ = analysis.resolve_annotation(annotation);
|
||||||
});
|
});
|
||||||
|
bar.inc(1);
|
||||||
}
|
}
|
||||||
|
bar.finish_and_clear();
|
||||||
|
|
||||||
let ide_time = sw.elapsed();
|
let ide_time = sw.elapsed();
|
||||||
eprintln!("{:<20} {} ({} files)", "IDE:", ide_time, file_ids.len());
|
eprintln!("{:<20} {} ({} files)", "IDE:", ide_time, file_ids.len());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user