More compact profiling display

This commit is contained in:
Aleksey Kladov 2019-12-22 14:17:31 +01:00
parent 6acef5a7c0
commit 08df355375

View file

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