diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2013-07-22 16:50:17 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2013-07-22 16:56:11 -0700 |
| commit | ca5ed4cc498ad5da22c6e1c4c0b79df07a07029e (patch) | |
| tree | 477222397ff4e9d588a679f6f2ae7a19140ff7c3 /src/libstd | |
| parent | 9f7e364d3a0f5d325f3722efb9c7ae4257b04e3d (diff) | |
| download | rust-ca5ed4cc498ad5da22c6e1c4c0b79df07a07029e.tar.gz rust-ca5ed4cc498ad5da22c6e1c4c0b79df07a07029e.zip | |
std: add benchmark for allocating-and-dropping a struct with a dtor.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ops.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libstd/ops.rs b/src/libstd/ops.rs index 020131ab119..756b4a10d3c 100644 --- a/src/libstd/ops.rs +++ b/src/libstd/ops.rs @@ -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 }; + } + } +} \ No newline at end of file |
