2020-03-08 23:14:04 +08:00
|
|
|
#![cfg_attr(feature = "unstable", feature(test))]
|
2015-12-20 16:46:05 +08:00
|
|
|
|
2020-03-08 23:14:04 +08:00
|
|
|
#[cfg(feature = "unstable")]
|
|
|
|
mod bench {
|
|
|
|
extern crate test;
|
2015-12-20 16:46:05 +08:00
|
|
|
|
2020-03-08 23:14:04 +08:00
|
|
|
use rusqlite::Connection;
|
|
|
|
use test::Bencher;
|
2015-12-20 16:46:05 +08:00
|
|
|
|
2020-03-08 23:14:04 +08:00
|
|
|
#[bench]
|
|
|
|
fn bench_no_cache(b: &mut Bencher) {
|
|
|
|
let db = Connection::open_in_memory().unwrap();
|
|
|
|
db.set_prepared_statement_cache_capacity(0);
|
|
|
|
let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71";
|
|
|
|
b.iter(|| db.prepare(sql).unwrap());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_cache(b: &mut Bencher) {
|
|
|
|
let db = Connection::open_in_memory().unwrap();
|
|
|
|
let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71";
|
|
|
|
b.iter(|| db.prepare_cached(sql).unwrap());
|
|
|
|
}
|
2020-03-14 14:41:57 +08:00
|
|
|
}
|