blob: 4cfaacdc4bc9e5d5e07d3aa17495701dd3ed6e29 [file] [log] [blame] [edit]
#![feature(test)]
extern crate thread_local;
extern crate test;
use thread_local::{ThreadLocal, CachedThreadLocal};
#[bench]
fn thread_local(b: &mut test::Bencher) {
let local = ThreadLocal::new();
b.iter(|| { let _: &i32 = local.get_or(|| Box::new(0)); });
}
#[bench]
fn cached_thread_local(b: &mut test::Bencher) {
let local = CachedThreadLocal::new();
b.iter(|| { let _: &i32 = local.get_or(|| Box::new(0)); });
}