1
0
Fork 0

add a context creation benchmark

This commit is contained in:
edef 2015-04-15 15:54:07 -04:00
parent f620005d0f
commit f7511dc2c1
1 changed files with 22 additions and 0 deletions

22
benches/context_new.rs Normal file
View File

@ -0,0 +1,22 @@
#![feature(test)]
extern crate test;
extern crate lwkt;
use lwkt::Context;
static mut ctx_slot: *mut Context = 0 as *mut Context;
#[bench]
fn context_new(b: &mut test::Bencher) {
b.iter(|| unsafe {
let mut ctx = Context::new(move || {
let ctx_ptr = ctx_slot;
loop {
(*ctx_ptr).swap()
}
});
ctx_slot = &mut ctx;
ctx.swap();
})
}