Skip to content

Commit

Permalink
Auto merge of #95454 - randomicon00:fix95444, r=wesleywiser
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed May 6, 2022
2 parents e209e85 + e79ba76 commit d60b4f5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion compiler/rustc_data_structures/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d60b4f5

Please sign in to comment.