std: add #[bench] benchmarks for global and local heaps.

This commit is contained in:
Graydon Hoare 2013-07-22 11:42:47 -07:00
parent e5cbede103
commit 3d5fb470fb
2 changed files with 38 additions and 0 deletions

View file

@ -101,3 +101,22 @@ pub unsafe fn exchange_free_(ptr: *c_char) {
pub unsafe fn exchange_free(ptr: *c_char) {
free(ptr as *c_void);
}
#[cfg(test)]
mod bench {
use extra::test::BenchHarness;
#[bench]
fn alloc_owned_small(bh: &mut BenchHarness) {
do bh.iter {
~10;
}
}
#[bench]
fn alloc_owned_big(bh: &mut BenchHarness) {
do bh.iter {
~[10, ..1000];
}
}
}

View file

@ -135,3 +135,22 @@ extern {
fn rust_boxed_region_free(region: *BoxedRegion, box: *OpaqueBox);
fn rust_current_boxed_region() -> *BoxedRegion;
}
#[cfg(test)]
mod bench {
use extra::test::BenchHarness;
#[bench]
fn alloc_managed_small(bh: &mut BenchHarness) {
do bh.iter {
@10;
}
}
#[bench]
fn alloc_managed_big(bh: &mut BenchHarness) {
do bh.iter {
@[10, ..1000];
}
}
}