2644: More compact profiling display r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-12-22 13:48:43 +00:00 committed by GitHub
commit 9f616ed65a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -217,7 +217,7 @@ fn print(
total: Option<Duration>,
) {
let mut last = 0;
let indent = repeat(" ").take(lvl + 1).collect::<String>();
let indent = repeat(" ").take(lvl).collect::<String>();
// We output hierarchy for long calls, but sum up all short calls
let mut short = Vec::new();
let mut accounted_for = Duration::default();
@ -227,7 +227,7 @@ fn print(
}
accounted_for += duration;
if duration >= longer_than {
writeln!(out, "{} {:6}ms - {}", indent, duration.as_millis(), msg)
writeln!(out, "{}{:5}ms - {}", indent, duration.as_millis(), msg)
.expect("printing profiling info to stdout");
print(lvl + 1, &msgs[last..i], out, longer_than, Some(duration));
@ -245,14 +245,14 @@ fn print(
count += 1;
total_duration += *time;
});
writeln!(out, "{} {:6}ms - {} ({} calls)", indent, total_duration.as_millis(), msg, count)
writeln!(out, "{}{:5}ms - {} ({} calls)", indent, total_duration.as_millis(), msg, count)
.expect("printing profiling info to stdout");
}
if let Some(total) = total {
if let Some(unaccounted) = total.checked_sub(accounted_for) {
if unaccounted >= longer_than && last > 0 {
writeln!(out, "{} {:6}ms - ???", indent, unaccounted.as_millis())
writeln!(out, "{}{:5}ms - ???", indent, unaccounted.as_millis())
.expect("printing profiling info to stdout");
}
}