libfringe/benches/swap.rs
edef 299a0a5d98 complete rewrite!
featuring 7ns inlineable context switches, no more separately-built
assembly objects, and a vastly nicer interface.
incontext/outcontext are no more, context switch calls now take a single
context structure, which functions as both.
everything now also functions without any heap allocations -- for the
context setup, only an FnOnce() value is necessary.
2015-01-14 11:27:43 +01:00

24 lines
371 B
Rust

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