Skip to content

Commit e79ba76

Browse files
committed
Fixing rust-lang#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
1 parent 5e1d19d commit e79ba76

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

compiler/rustc_data_structures/src/profiling.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,30 @@ impl Drop for VerboseTimingGuard<'_> {
649649
fn drop(&mut self) {
650650
if let Some((start_time, start_rss, ref message)) = self.start_and_message {
651651
let end_rss = get_resident_set_size();
652-
print_time_passes_entry(&message, start_time.elapsed(), start_rss, end_rss);
652+
let dur = start_time.elapsed();
653+
654+
if should_print_passes(dur, start_rss, end_rss) {
655+
print_time_passes_entry(&message, dur, start_rss, end_rss);
656+
}
653657
}
654658
}
655659
}
656660

661+
fn should_print_passes(dur: Duration, start_rss: Option<usize>, end_rss: Option<usize>) -> bool {
662+
if dur.as_millis() > 5 {
663+
return true;
664+
}
665+
666+
if let (Some(start_rss), Some(end_rss)) = (start_rss, end_rss) {
667+
let change_rss = end_rss.abs_diff(start_rss);
668+
if change_rss > 0 {
669+
return true;
670+
}
671+
}
672+
673+
false
674+
}
675+
657676
pub fn print_time_passes_entry(
658677
what: &str,
659678
dur: Duration,

0 commit comments

Comments
 (0)