diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2013-07-22 11:42:47 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2013-07-22 16:56:10 -0700 |
| commit | 3d5fb470fb22dea6473fc1a4d265ce9494dd4120 (patch) | |
| tree | 661f9e192acecb06b253103316ffe38fd3a92634 /src/libstd/rt | |
| parent | e5cbede103fca018089b113ec35f0cf863df7106 (diff) | |
| download | rust-3d5fb470fb22dea6473fc1a4d265ce9494dd4120.tar.gz rust-3d5fb470fb22dea6473fc1a4d265ce9494dd4120.zip | |
std: add #[bench] benchmarks for global and local heaps.
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/global_heap.rs | 19 | ||||
| -rw-r--r-- | src/libstd/rt/local_heap.rs | 19 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 580390c1953..54e9cb263db 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -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]; + } + } +} diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index c909bdb6285..85917ae3edf 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -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]; + } + } +} |
