std: add benchmark for allocating-and-dropping a struct with a dtor.
This commit is contained in:
parent
9f7e364d3a
commit
ca5ed4cc49
1 changed files with 25 additions and 0 deletions
|
|
@ -81,3 +81,28 @@ pub trait Shr<RHS,Result> {
|
|||
pub trait Index<Index,Result> {
|
||||
fn index(&self, index: &Index) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod bench {
|
||||
|
||||
use extra::test::BenchHarness;
|
||||
use ops::Drop;
|
||||
|
||||
// Overhead of dtors
|
||||
|
||||
struct HasDtor {
|
||||
x: int
|
||||
}
|
||||
|
||||
impl Drop for HasDtor {
|
||||
fn drop(&self) {
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn alloc_obj_with_dtor(bh: &mut BenchHarness) {
|
||||
do bh.iter {
|
||||
HasDtor { x : 10 };
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue