mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-25 02:21:37 +08:00
Add benchmarks for statement cache.
This commit is contained in:
parent
1ec2dee533
commit
9b4fdc29ee
23
benches/lib.rs
Normal file
23
benches/lib.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#![feature(test)]
|
||||||
|
extern crate test;
|
||||||
|
|
||||||
|
extern crate rusqlite;
|
||||||
|
|
||||||
|
use rusqlite::Connection;
|
||||||
|
use rusqlite::cache::StatementCache;
|
||||||
|
use test::Bencher;
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_no_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(sql).unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_cache(b: &mut Bencher) {
|
||||||
|
let db = Connection::open_in_memory().unwrap();
|
||||||
|
let cache = StatementCache::new(&db, 15);
|
||||||
|
let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71";
|
||||||
|
b.iter(|| cache.get(sql).unwrap());
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user