Compare performance to rusqlite

This commit is contained in:
Pekka Enberg
2023-09-02 21:22:38 +03:00
parent f92a83d083
commit 9b268dcc6f
3 changed files with 101 additions and 2 deletions

72
Cargo.lock generated
View File

@@ -38,6 +38,12 @@ dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]]
name = "anes"
version = "0.1.6"
@@ -475,12 +481,24 @@ dependencies = [
"str-buf",
]
[[package]]
name = "fallible-iterator"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
[[package]]
name = "fallible-iterator"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
[[package]]
name = "fallible-streaming-iterator"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]]
name = "fastrand"
version = "2.0.0"
@@ -615,6 +633,19 @@ name = "hashbrown"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
dependencies = [
"ahash",
"allocator-api2",
]
[[package]]
name = "hashlink"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7"
dependencies = [
"hashbrown",
]
[[package]]
name = "heck"
@@ -722,6 +753,16 @@ dependencies = [
"libc",
]
[[package]]
name = "libsqlite3-sys"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326"
dependencies = [
"pkg-config",
"vcpkg",
]
[[package]]
name = "lig"
version = "0.0.0"
@@ -750,10 +791,11 @@ dependencies = [
"anyhow",
"concurrent_lru",
"criterion",
"fallible-iterator",
"fallible-iterator 0.3.0",
"log",
"mimalloc",
"pprof",
"rusqlite",
"sqlite3-parser",
]
@@ -971,6 +1013,12 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
[[package]]
name = "plotters"
version = "0.3.5"
@@ -1162,6 +1210,20 @@ dependencies = [
"bytemuck",
]
[[package]]
name = "rusqlite"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "549b9d036d571d42e6e85d1c1425e2ac83491075078ca9a15be021c56b1641f2"
dependencies = [
"bitflags 2.4.0",
"fallible-iterator 0.2.0",
"fallible-streaming-iterator",
"hashlink",
"libsqlite3-sys",
"smallvec",
]
[[package]]
name = "rustc-demangle"
version = "0.1.23"
@@ -1285,7 +1347,7 @@ checksum = "3b64003a3617746eb65b39e6dc422139a2f99cfd54683fc973f4763eb786e0c1"
dependencies = [
"bitflags 2.4.0",
"cc",
"fallible-iterator",
"fallible-iterator 0.3.0",
"indexmap",
"log",
"memchr",
@@ -1456,6 +1518,12 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.9.4"

View File

@@ -24,6 +24,7 @@ sqlite3-parser = "0.11.0"
[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports", "async", "async_futures"] }
pprof = { version = "0.12.1", features = ["criterion", "flamegraph"] }
rusqlite = "0.29.0"
[[bench]]
name = "benchmark"

View File

@@ -88,6 +88,36 @@ fn bench(c: &mut Criterion) {
});
},
);
drop(group);
let mut group = c.benchmark_group("rusqlite");
group.throughput(Throughput::Elements(1));
let conn = rusqlite::Connection::open("../testing/hello.db").unwrap();
let mut stmt = conn.prepare("SELECT 1").unwrap();
group.bench_function("Execute prepared statement: 'SELECT 1'", |b| {
b.iter(|| {
let mut rows = stmt.query(()).unwrap();
let row = rows.next().unwrap().unwrap();
let val: i64 = row.get(0).unwrap();
assert_eq!(val, 1);
});
});
let mut stmt = conn.prepare("SELECT * FROM users LIMIT 1").unwrap();
group.bench_function(
"Execute prepared statement: 'SELECT * FROM users LIMIT 1'",
|b| {
b.iter(|| {
let mut rows = stmt.query(()).unwrap();
let row = rows.next().unwrap().unwrap();
let id: i64 = row.get(0).unwrap();
assert_eq!(id, 1);
});
},
);
}
criterion_group! {