0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2024-12-16 06:48:48 +00:00
2023-10-17 10:36:28 +02:00

19 lines
633 B
Rust

use bencher::{benchmark_group, benchmark_main, Bencher};
use rusqlite::Connection;
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());
}
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());
}
benchmark_group!(cache_benches, bench_no_cache, bench_cache);
benchmark_main!(cache_benches);