Skip to content

Commit

Permalink
std: add benchmark for allocating-and-dropping a struct with a dtor.
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon committed Jul 22, 2013
1 parent 9f7e364 commit ca5ed4c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/libstd/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
}
}

0 comments on commit ca5ed4c

Please sign in to comment.