mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-21 21:09:23 +08:00
Use bencher
instead of unstable libtest
This commit is contained in:
parent
c0df911946
commit
7e4ff77a43
@ -56,7 +56,6 @@ series = ["vtab"]
|
||||
# check for invalid query.
|
||||
extra_check = []
|
||||
modern_sqlite = ["libsqlite3-sys/bundled_bindings"]
|
||||
unstable = []
|
||||
in_gecko = ["modern_sqlite", "libsqlite3-sys/in_gecko"]
|
||||
bundled-windows = ["libsqlite3-sys/bundled-windows"]
|
||||
|
||||
@ -82,6 +81,9 @@ lazy_static = "1.0"
|
||||
regex = "1.0"
|
||||
uuid = { version = "0.8", features = ["v4"] }
|
||||
unicase = "2.4.0"
|
||||
# Use `bencher` over criterion becasue it builds much faster and we don't have
|
||||
# many benchmarks
|
||||
bencher = "0.1"
|
||||
|
||||
[dependencies.libsqlite3-sys]
|
||||
path = "libsqlite3-sys"
|
||||
@ -97,6 +99,10 @@ name = "deny_single_threaded_sqlite_config"
|
||||
[[test]]
|
||||
name = "vtab"
|
||||
|
||||
[[bench]]
|
||||
name = "cache"
|
||||
harness = false
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = [ "backup", "blob", "chrono", "collation", "functions", "limits", "load_extension", "serde_json", "trace", "url", "vtab", "window", "modern_sqlite" ]
|
||||
all-features = false
|
||||
|
18
benches/cache.rs
Normal file
18
benches/cache.rs
Normal file
@ -0,0 +1,18 @@
|
||||
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);
|
@ -1,24 +0,0 @@
|
||||
#![cfg_attr(feature = "unstable", feature(test))]
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
mod bench {
|
||||
extern crate test;
|
||||
|
||||
use rusqlite::Connection;
|
||||
use test::Bencher;
|
||||
|
||||
#[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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user