forked from M-Labs/libfringe
add a context creation benchmark
This commit is contained in:
parent
f620005d0f
commit
f7511dc2c1
|
@ -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();
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue