1 //! Various batch processing tasks, intended primarily for debugging.
19 use ide::AnalysisHost;
22 #[derive(Clone, Copy)]
31 pub fn is_verbose(self) -> bool {
32 matches!(self, Verbosity::Verbose | Verbosity::Spammy)
34 pub fn is_spammy(self) -> bool {
35 matches!(self, Verbosity::Spammy)
39 fn read_stdin() -> Result<String> {
40 let mut buff = String::new();
41 std::io::stdin().read_to_string(&mut buff)?;
45 fn report_metric(metric: &str, value: u64, unit: &str) {
46 if std::env::var("RA_METRICS").is_err() {
49 println!("METRIC:{}:{}:{}", metric, value, unit)
52 fn print_memory_usage(mut host: AnalysisHost, vfs: Vfs) {
53 let mut mem = host.per_query_memory_usage();
55 let before = profile::memory_usage();
57 let vfs = before.allocated - profile::memory_usage().allocated;
58 mem.push(("VFS".into(), vfs));
60 let before = profile::memory_usage();
62 mem.push(("Unaccounted".into(), before.allocated - profile::memory_usage().allocated));
64 mem.push(("Remaining".into(), profile::memory_usage().allocated));
66 for (name, bytes) in mem {
67 // NOTE: Not a debug print, so avoid going through the `eprintln` defined above.
68 eprintln!("{:>8} {}", bytes, name);