mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
internal: make non-zero times stand out in profile
This commit is contained in:
parent
08756012a5
commit
a5049e13bf
1 changed files with 17 additions and 6 deletions
|
@ -2,7 +2,7 @@
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
collections::{BTreeMap, HashSet},
|
collections::{BTreeMap, HashSet},
|
||||||
env,
|
env, fmt,
|
||||||
io::{stderr, Write},
|
io::{stderr, Write},
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
|
@ -278,9 +278,9 @@ fn print(
|
||||||
let detail = tree[curr].detail.as_ref().map(|it| format!(" @ {}", it)).unwrap_or_default();
|
let detail = tree[curr].detail.as_ref().map(|it| format!(" @ {}", it)).unwrap_or_default();
|
||||||
writeln!(
|
writeln!(
|
||||||
out,
|
out,
|
||||||
"{}{:5}ms - {}{}",
|
"{}{} - {}{}",
|
||||||
current_indent,
|
current_indent,
|
||||||
tree[curr].duration.as_millis(),
|
ms(tree[curr].duration),
|
||||||
tree[curr].label,
|
tree[curr].label,
|
||||||
detail,
|
detail,
|
||||||
)
|
)
|
||||||
|
@ -302,14 +302,25 @@ fn print(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (child_msg, (duration, count)) in short_children.iter() {
|
for (child_msg, (duration, count)) in short_children.iter() {
|
||||||
let millis = duration.as_millis();
|
writeln!(out, " {}{} - {} ({} calls)", current_indent, ms(*duration), child_msg, count)
|
||||||
writeln!(out, " {}{:5}ms - {} ({} calls)", current_indent, millis, child_msg, count)
|
|
||||||
.expect("printing profiling info");
|
.expect("printing profiling info");
|
||||||
}
|
}
|
||||||
|
|
||||||
let unaccounted = tree[curr].duration - accounted_for;
|
let unaccounted = tree[curr].duration - accounted_for;
|
||||||
if tree.children(curr).next().is_some() && unaccounted > longer_than {
|
if tree.children(curr).next().is_some() && unaccounted > longer_than {
|
||||||
writeln!(out, " {}{:5}ms - ???", current_indent, unaccounted.as_millis())
|
writeln!(out, " {}{} - ???", current_indent, ms(unaccounted))
|
||||||
.expect("printing profiling info");
|
.expect("printing profiling info");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
struct ms(Duration);
|
||||||
|
|
||||||
|
impl fmt::Display for ms {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self.0.as_millis() {
|
||||||
|
0 => f.write_str(" 0 "),
|
||||||
|
n => write!(f, "{:5}ms", n),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue