about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/profiling.rs
diff options
context:
space:
mode:
authorPeh <20146907+randomicon00@users.noreply.github.com>2022-03-30 00:29:29 +0000
committerPeh <20146907+randomicon00@users.noreply.github.com>2022-05-05 23:56:40 +0000
commite79ba76ec462031c9d5fa2130bc631600bc6d875 (patch)
tree76ca42133ed474ecd2768fb965cb9552a9dbad80 /compiler/rustc_data_structures/src/profiling.rs
parent5e1d19d30723c287f049662474021f2b9a9894ce (diff)
downloadrust-e79ba76ec462031c9d5fa2130bc631600bc6d875.tar.gz
rust-e79ba76ec462031c9d5fa2130bc631600bc6d875.zip
Fixing #95444 by only displaying passes that take more than 5 milliseconds
95444: Adding passes that include memory increase

Fix95444: Change the substraction with the abs_diff() method

Fix95444: Change the substraction with abs_diff() method
Diffstat (limited to 'compiler/rustc_data_structures/src/profiling.rs')
-rw-r--r--compiler/rustc_data_structures/src/profiling.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs
index fd6ff086b08..e122536f61f 100644
--- a/compiler/rustc_data_structures/src/profiling.rs
+++ b/compiler/rustc_data_structures/src/profiling.rs
@@ -649,11 +649,30 @@ impl Drop for VerboseTimingGuard<'_> {
     fn drop(&mut self) {
         if let Some((start_time, start_rss, ref message)) = self.start_and_message {
             let end_rss = get_resident_set_size();
-            print_time_passes_entry(&message, start_time.elapsed(), start_rss, end_rss);
+            let dur = start_time.elapsed();
+
+            if should_print_passes(dur, start_rss, end_rss) {
+                print_time_passes_entry(&message, dur, start_rss, end_rss);
+            }
         }
     }
 }
 
+fn should_print_passes(dur: Duration, start_rss: Option<usize>, end_rss: Option<usize>) -> bool {
+    if dur.as_millis() > 5 {
+        return true;
+    }
+
+    if let (Some(start_rss), Some(end_rss)) = (start_rss, end_rss) {
+        let change_rss = end_rss.abs_diff(start_rss);
+        if change_rss > 0 {
+            return true;
+        }
+    }
+
+    false
+}
+
 pub fn print_time_passes_entry(
     what: &str,
     dur: Duration,