libfringe/benches/swap.rs

24 lines
371 B
Rust
Raw Normal View History

2014-12-23 11:24:40 +08:00
extern crate test;
extern crate lwkt;
use lwkt::Context;
static mut ctx_slot: *mut Context = 0 as *mut Context;
2014-12-23 11:24:40 +08:00
#[bench]
fn swap(b: &mut test::Bencher) {
unsafe {
let mut ctx = Context::new(move |:| {
let ctx_ptr = ctx_slot;
loop {
(*ctx_ptr).swap()
}
});
2014-12-23 11:24:40 +08:00
ctx_slot = &mut ctx;
2014-12-23 11:24:40 +08:00
ctx.swap();
2014-12-23 11:24:40 +08:00
b.iter(|| ctx.swap());
2014-12-23 11:24:40 +08:00
}
}