aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Kuehn <tkuehn@cmu.edu>2013-08-29 00:42:20 -0400
committerTim Kuehn <tkuehn@cmu.edu>2013-08-29 00:42:20 -0400
commitcf4107e262c7dee71382b8400090c376e7bce7fe (patch)
treefe57cacc15258cb0533fe273f0e942b7936ec61c
parent47ec798b92f35134d9324d81bd5c8a6fe6ffa094 (diff)
downloadservo-cf4107e262c7dee71382b8400090c376e7bce7fe.tar.gz
servo-cf4107e262c7dee71382b8400090c376e7bce7fe.zip
use TreeMap instead of HashMap for profiler buckets
-rw-r--r--src/components/util/time.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/components/util/time.rs b/src/components/util/time.rs
index a8455a67028..58cd8210040 100644
--- a/src/components/util/time.rs
+++ b/src/components/util/time.rs
@@ -8,7 +8,7 @@ use std::cell::Cell;
use std::comm::{Port, SharedChan};
use extra::sort::tim_sort;
use std::iterator::AdditiveIterator;
-use std::hashmap::HashMap;
+use extra::treemap::TreeMap;
// front-end representation of the profiler used to communicate with the profiler
#[deriving(Clone)]
@@ -34,7 +34,7 @@ pub enum ProfilerMsg {
PrintMsg,
}
-#[deriving(Eq, Clone, IterBytes)]
+#[deriving(Eq, Clone, TotalEq, TotalOrd)]
pub enum ProfilerCategory {
CompositingCategory,
LayoutQueryCategory,
@@ -52,7 +52,7 @@ pub enum ProfilerCategory {
// FIXME(rust#8803): workaround for lack of CTFE function on enum types to return length
NumBuckets,
}
-type ProfilerBuckets = HashMap<ProfilerCategory, ~[float]>;
+type ProfilerBuckets = TreeMap<ProfilerCategory, ~[float]>;
// back end of the profiler that handles data aggregation and performance metrics
pub struct Profiler {
@@ -69,7 +69,7 @@ impl ProfilerCategory {
// enumeration of all ProfilerCategory types
fn empty_buckets() -> ProfilerBuckets {
- let mut buckets = HashMap::with_capacity(NumBuckets as uint);
+ let mut buckets = TreeMap::new();
buckets.insert(CompositingCategory, ~[]);
buckets.insert(LayoutQueryCategory, ~[]);
buckets.insert(LayoutPerformCategory, ~[]);
@@ -128,7 +128,7 @@ impl Profiler {
fn handle_msg(&mut self, msg: ProfilerMsg) {
match msg {
- TimeMsg(category, t) => self.buckets.get_mut(&category).push(t),
+ TimeMsg(category, t) => self.buckets.find_mut(&category).unwrap().push(t),
PrintMsg => match self.last_msg {
// only print if more data has arrived since the last printout
Some(TimeMsg(*)) => self.print_buckets(),
@@ -142,8 +142,10 @@ impl Profiler {
println(fmt!("%31s %15s %15s %15s %15s %15s",
"_category_", "_mean (ms)_", "_median (ms)_",
"_min (ms)_", "_max (ms)_", "_bucket size_"));
- for (category, data) in self.buckets.mut_iter() {
- tim_sort(*data);
+ for (category, data) in self.buckets.iter() {
+ // FIXME(XXX): TreeMap currently lacks mut_iter()
+ let mut data = data.clone();
+ tim_sort(data);
let data_len = data.len();
if data_len > 0 {
let (mean, median, &min, &max) =