mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Take the stdout lock when printing profile data
Acquiring the stdout lock while printing the profile data prevents other messages printed to stdout from being interleaved with prints from elsewhere.
This commit is contained in:
parent
4f6331953e
commit
1997d034fa
1 changed files with 10 additions and 5 deletions
|
@ -12,6 +12,7 @@ use profile_traits::time::{TimerMetadataReflowType, TimerMetadataFrameType};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::io::{self, Write};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::{thread, f64};
|
use std::{thread, f64};
|
||||||
use std_time::precise_time_ns;
|
use std_time::precise_time_ns;
|
||||||
|
@ -251,10 +252,13 @@ impl Profiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_buckets(&mut self) {
|
fn print_buckets(&mut self) {
|
||||||
println!("{:35} {:14} {:9} {:30} {:15} {:15} {:-15} {:-15} {:-15}",
|
let stdout = io::stdout();
|
||||||
|
let mut lock = stdout.lock();
|
||||||
|
|
||||||
|
writeln!(&mut lock, "{:35} {:14} {:9} {:30} {:15} {:15} {:-15} {:-15} {:-15}",
|
||||||
"_category_", "_incremental?_", "_iframe?_",
|
"_category_", "_incremental?_", "_iframe?_",
|
||||||
" _url_", " _mean (ms)_", " _median (ms)_",
|
" _url_", " _mean (ms)_", " _median (ms)_",
|
||||||
" _min (ms)_", " _max (ms)_", " _events_");
|
" _min (ms)_", " _max (ms)_", " _events_").unwrap();
|
||||||
for (&(ref category, ref meta), ref mut data) in &mut self.buckets {
|
for (&(ref category, ref meta), ref mut data) in &mut self.buckets {
|
||||||
data.sort_by(|a, b| {
|
data.sort_by(|a, b| {
|
||||||
if a < b {
|
if a < b {
|
||||||
|
@ -270,11 +274,12 @@ impl Profiler {
|
||||||
data[data_len / 2],
|
data[data_len / 2],
|
||||||
data.iter().fold(f64::INFINITY, |a, &b| a.min(b)),
|
data.iter().fold(f64::INFINITY, |a, &b| a.min(b)),
|
||||||
data.iter().fold(-f64::INFINITY, |a, &b| a.max(b)));
|
data.iter().fold(-f64::INFINITY, |a, &b| a.max(b)));
|
||||||
println!("{:-35}{} {:15.4} {:15.4} {:15.4} {:15.4} {:15}",
|
writeln!(&mut lock, "{:-35}{} {:15.4} {:15.4} {:15.4} {:15.4} {:15}",
|
||||||
category.format(), meta.format(), mean, median, min, max, data_len);
|
category.format(), meta.format(), mean, median, min, max,
|
||||||
|
data_len).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("");
|
writeln!(&mut lock, "").unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue