diff options
| author | bors <bors@rust-lang.org> | 2022-05-06 17:52:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-06 17:52:47 +0000 |
| commit | d60b4f52c92facae291151dd5a23399f8044d01e (patch) | |
| tree | 840e698453edcedb23f76ea7d8ad9bf964e526d8 /compiler/rustc_data_structures/src/profiling.rs | |
| parent | e209e85e39b4851c3ec122a45ddeabe318b2d522 (diff) | |
| parent | e79ba76ec462031c9d5fa2130bc631600bc6d875 (diff) | |
| download | rust-d60b4f52c92facae291151dd5a23399f8044d01e.tar.gz rust-d60b4f52c92facae291151dd5a23399f8044d01e.zip | |
Auto merge of #95454 - randomicon00:fix95444, r=wesleywiser
Fixing #95444 by only displaying passes that take more than 5 millise⦠As discussed in #95444, I have added the code to test and only display prints that are greater than 5 milliseconds. r? `@jyn514`
Diffstat (limited to 'compiler/rustc_data_structures/src/profiling.rs')
| -rw-r--r-- | compiler/rustc_data_structures/src/profiling.rs | 21 |
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 3f7a90a8467..bf7924a81ff 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -737,11 +737,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, |
