2018-11-01 16:40:56 +08:00
|
|
|
#![feature(extern_crate_item_prelude)]
|
2015-12-20 16:46:05 +08:00
|
|
|
#![feature(test)]
|
|
|
|
extern crate test;
|
|
|
|
|
|
|
|
extern crate rusqlite;
|
|
|
|
|
|
|
|
use rusqlite::Connection;
|
|
|
|
use test::Bencher;
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_no_cache(b: &mut Bencher) {
|
|
|
|
let db = Connection::open_in_memory().unwrap();
|
2017-02-25 03:10:51 +08:00
|
|
|
db.set_prepared_statement_cache_capacity(0);
|
2015-12-20 16:46:05 +08:00
|
|
|
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";
|
2017-02-25 03:10:51 +08:00
|
|
|
b.iter(|| db.prepare_cached(sql).unwrap());
|
2015-12-20 16:46:05 +08:00
|
|
|
}
|