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