Skip to content

Commit d60b4f5

Browse files
committed
Auto merge of rust-lang#95454 - randomicon00:fix95444, r=wesleywiser
Fixing rust-lang#95444 by only displaying passes that take more than 5 millise… As discussed in rust-lang#95444, I have added the code to test and only display prints that are greater than 5 milliseconds. r? `@jyn514`
2 parents e209e85 + e79ba76 commit d60b4f5

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
@@ -737,11 +737,30 @@ impl Drop for VerboseTimingGuard<'_> {
737737
fn drop(&mut self) {
738738
if let Some((start_time, start_rss, ref message)) = self.start_and_message {
739739
let end_rss = get_resident_set_size();
740-
print_time_passes_entry(&message, start_time.elapsed(), start_rss, end_rss);
740+
let dur = start_time.elapsed();
741+
742+
if should_print_passes(dur, start_rss, end_rss) {
743+
print_time_passes_entry(&message, dur, start_rss, end_rss);
744+
}
741745
}
742746
}
743747
}
744748

749+
fn should_print_passes(dur: Duration, start_rss: Option<usize>, end_rss: Option<usize>) -> bool {
750+
if dur.as_millis() > 5 {
751+
return true;
752+
}
753+
754+
if let (Some(start_rss), Some(end_rss)) = (start_rss, end_rss) {
755+
let change_rss = end_rss.abs_diff(start_rss);
756+
if change_rss > 0 {
757+
return true;
758+
}
759+
}
760+
761+
false
762+
}
763+
745764
pub fn print_time_passes_entry(
746765
what: &str,
747766
dur: Duration,

0 commit comments

Comments
 (0)