mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
add tests for profiler buckets
This commit is contained in:
parent
ca620992a6
commit
4c1648f8f5
1 changed files with 13 additions and 16 deletions
|
@ -80,9 +80,8 @@ impl ProfilerCategory {
|
||||||
}
|
}
|
||||||
|
|
||||||
// enumeration of all ProfilerCategory types
|
// enumeration of all ProfilerCategory types
|
||||||
// TODO(tkuehn): is there a better way to ensure proper order of categories?
|
|
||||||
fn empty_buckets() -> ProfilerBuckets {
|
fn empty_buckets() -> ProfilerBuckets {
|
||||||
let buckets = [
|
[
|
||||||
ProfilerBucket::new(CompositingCategory),
|
ProfilerBucket::new(CompositingCategory),
|
||||||
ProfilerBucket::new(LayoutQueryCategory),
|
ProfilerBucket::new(LayoutQueryCategory),
|
||||||
ProfilerBucket::new(LayoutPerformCategory),
|
ProfilerBucket::new(LayoutPerformCategory),
|
||||||
|
@ -96,19 +95,7 @@ impl ProfilerCategory {
|
||||||
ProfilerBucket::new(RenderingDrawingCategory),
|
ProfilerBucket::new(RenderingDrawingCategory),
|
||||||
ProfilerBucket::new(RenderingPrepBuffCategory),
|
ProfilerBucket::new(RenderingPrepBuffCategory),
|
||||||
ProfilerBucket::new(RenderingCategory),
|
ProfilerBucket::new(RenderingCategory),
|
||||||
];
|
]
|
||||||
|
|
||||||
ProfilerCategory::check_order(&buckets);
|
|
||||||
buckets
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure that the order of the buckets matches the order of the enum categories
|
|
||||||
fn check_order(vec: &ProfilerBuckets) {
|
|
||||||
for (i, bucket) in vec.iter().enumerate() {
|
|
||||||
if bucket.category as uint != i {
|
|
||||||
fail!("Enum category does not match bucket index. This is a bug.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// some categories are subcategories of LayoutPerformCategory
|
// some categories are subcategories of LayoutPerformCategory
|
||||||
|
@ -207,4 +194,14 @@ pub fn time<T>(msg: &str, callback: &fn() -> T) -> T{
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
// ensure that the order of the buckets matches the order of the enum categories
|
||||||
|
#[test]
|
||||||
|
fn check_order() {
|
||||||
|
let buckets = ProfilerCategory::empty_buckets();
|
||||||
|
for (i, bucket) in buckets.iter().enumerate() {
|
||||||
|
assert!(bucket.category as uint == i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue