#![feature(test)] extern crate persawkv; extern crate test; use persawkv::{prelude::*, SingleKV}; #[cfg(test)] mod benches { use super::*; use test::Bencher; macro_rules! bench_teardown { ($p:ident) => { std::thread::sleep(std::time::Duration::from_secs(1)); let _ = std::fs::remove_file($p); }; } #[bench] fn bench_raw_get_int(b: &mut Bencher) { let test_cab_path = "./tmp/bench_raw_get.persy"; let test_store = SingleKV::::new(test_cab_path, "traw").unwrap(); let _ = test_store.insert("test".to_string(), 1); let test_string = "test".to_string(); b.iter(|| { let _ = test_store.get(&test_string); }); bench_teardown!(test_cab_path); } #[bench] fn bench_raw_insert_get_int(b: &mut Bencher) { let test_cab_path = "./tmp/bench_raw_insert_get.persy"; let test_store = SingleKV::::new(test_cab_path, "traw").unwrap(); let test_string = "test".to_string(); b.iter(|| { let _ = test_store.insert("test".to_string(), 1); let _ = test_store.get(&test_string); }); bench_teardown!(test_cab_path); } #[bench] fn bench_pure_insert_get_int(b: &mut Bencher) { let test_cab_path = "./tmp/bench_pure_insert_get.persy"; let test_store = SingleKV::::new(test_cab_path, "traw").unwrap(); b.iter(|| { let _ = test_store.insert(1, 1); let _ = test_store.get(&1); }); bench_teardown!(test_cab_path); } }