2020-02-18 05:11:32 -06:00
|
|
|
//! Various batch processing tasks, intended primarily for debugging.
|
2020-02-17 12:03:03 -06:00
|
|
|
|
2021-08-10 04:25:47 -05:00
|
|
|
pub mod flags;
|
2021-08-01 09:34:51 -05:00
|
|
|
pub mod load_cargo;
|
2021-08-10 04:49:55 -05:00
|
|
|
mod parse;
|
|
|
|
mod symbols;
|
|
|
|
mod highlight;
|
2020-02-17 12:03:03 -06:00
|
|
|
mod analysis_stats;
|
2020-04-13 07:44:35 -05:00
|
|
|
mod diagnostics;
|
2020-06-27 02:31:50 -05:00
|
|
|
mod ssr;
|
2020-02-17 12:03:03 -06:00
|
|
|
|
2021-08-10 04:49:55 -05:00
|
|
|
mod progress_report;
|
|
|
|
|
2020-02-17 12:03:03 -06:00
|
|
|
use std::io::Read;
|
|
|
|
|
|
|
|
use anyhow::Result;
|
2021-08-10 04:49:55 -05:00
|
|
|
use ide::AnalysisHost;
|
2020-12-11 11:24:27 -06:00
|
|
|
use vfs::Vfs;
|
2020-02-17 12:03:03 -06:00
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
pub enum Verbosity {
|
|
|
|
Spammy,
|
|
|
|
Verbose,
|
|
|
|
Normal,
|
|
|
|
Quiet,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Verbosity {
|
|
|
|
pub fn is_verbose(self) -> bool {
|
2020-06-27 20:02:03 -05:00
|
|
|
matches!(self, Verbosity::Verbose | Verbosity::Spammy)
|
2020-02-17 12:03:03 -06:00
|
|
|
}
|
|
|
|
pub fn is_spammy(self) -> bool {
|
2020-06-27 20:02:03 -05:00
|
|
|
matches!(self, Verbosity::Spammy)
|
2020-02-17 12:03:03 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn read_stdin() -> Result<String> {
|
|
|
|
let mut buff = String::new();
|
|
|
|
std::io::stdin().read_to_string(&mut buff)?;
|
|
|
|
Ok(buff)
|
|
|
|
}
|
2020-07-25 03:35:45 -05:00
|
|
|
|
|
|
|
fn report_metric(metric: &str, value: u64, unit: &str) {
|
|
|
|
if std::env::var("RA_METRICS").is_err() {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
println!("METRIC:{}:{}:{}", metric, value, unit)
|
|
|
|
}
|
2020-12-11 11:24:27 -06:00
|
|
|
|
|
|
|
fn print_memory_usage(mut host: AnalysisHost, vfs: Vfs) {
|
|
|
|
let mut mem = host.per_query_memory_usage();
|
|
|
|
|
|
|
|
let before = profile::memory_usage();
|
|
|
|
drop(vfs);
|
|
|
|
let vfs = before.allocated - profile::memory_usage().allocated;
|
|
|
|
mem.push(("VFS".into(), vfs));
|
|
|
|
|
|
|
|
let before = profile::memory_usage();
|
|
|
|
drop(host);
|
|
|
|
mem.push(("Unaccounted".into(), before.allocated - profile::memory_usage().allocated));
|
|
|
|
|
|
|
|
mem.push(("Remaining".into(), profile::memory_usage().allocated));
|
|
|
|
|
|
|
|
for (name, bytes) in mem {
|
|
|
|
// NOTE: Not a debug print, so avoid going through the `eprintln` defined above.
|
|
|
|
eprintln!("{:>8} {}", bytes, name);
|
|
|
|
}
|
|
|
|
}
|