Use larger and more realistic database for testing

This commit is contained in:
Pekka Enberg 2024-06-29 10:02:19 +03:00
parent 4d8e0f1214
commit cc101b1b00
6 changed files with 41 additions and 5 deletions

View file

@ -8,7 +8,7 @@ fn bench(c: &mut Criterion) {
group.throughput(Throughput::Elements(1));
let io = Rc::new(PlatformIO::new().unwrap());
let db = Database::open_file(io.clone(), "../testing/hello.db").unwrap();
let db = Database::open_file(io.clone(), "../testing/database.db").unwrap();
let conn = db.connect();
let mut stmt = conn.prepare("SELECT 1").unwrap();
@ -54,12 +54,35 @@ fn bench(c: &mut Criterion) {
},
);
let mut stmt = conn.prepare("SELECT * FROM users LIMIT 100").unwrap();
group.bench_function(
"Execute prepared statement: 'SELECT * FROM users LIMIT 100'",
|b| {
let io = io.clone();
b.iter(|| {
let mut rows = stmt.query().unwrap();
match rows.next().unwrap() {
limbo_core::RowResult::Row(row) => {
assert_eq!(row.get::<i64>(0).unwrap(), 1);
}
limbo_core::RowResult::IO => {
io.run_once().unwrap();
}
limbo_core::RowResult::Done => {
unreachable!();
}
}
stmt.reset();
});
},
);
drop(group);
let mut group = c.benchmark_group("rusqlite");
group.throughput(Throughput::Elements(1));
let conn = rusqlite::Connection::open("../testing/hello.db").unwrap();
let conn = rusqlite::Connection::open("../testing/testing.db").unwrap();
let mut stmt = conn.prepare("SELECT 1").unwrap();
group.bench_function("Execute prepared statement: 'SELECT 1'", |b| {
@ -83,6 +106,19 @@ fn bench(c: &mut Criterion) {
});
},
);
let mut stmt = conn.prepare("SELECT * FROM users LIMIT 100").unwrap();
group.bench_function(
"Execute prepared statement: 'SELECT * FROM users LIMIT 100'",
|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! {

View file

@ -14,7 +14,7 @@ fn main() {
let mut rng = ChaCha8Rng::seed_from_u64(seed);
let io = Rc::new(SimulatorIO::new().unwrap());
for _ in 0..100000 {
let db = match Database::open_file(io.clone(), "./testing/hello.db") {
let db = match Database::open_file(io.clone(), "./testing/testing.db") {
Ok(db) => db,
Err(_) => continue,
};

View file

@ -25,6 +25,6 @@ void test_open_existing(void)
{
sqlite3 *db;
CHECK_EQUAL(SQLITE_OK, sqlite3_open("../../testing/hello.db", &db));
CHECK_EQUAL(SQLITE_OK, sqlite3_open("../../testing/testing.db", &db));
CHECK_EQUAL(SQLITE_OK, sqlite3_close(db));
}

View file

@ -3,7 +3,7 @@
set sqlite_exec [expr {[info exists env(SQLITE_EXEC)] ? $env(SQLITE_EXEC) : "sqlite3"}]
proc evaluate_sql {sqlite_exec sql} {
set command [list $sqlite_exec testing/hello.db $sql]
set command [list $sqlite_exec testing/testing.db $sql]
set output [exec {*}$command]
return $output
}

Binary file not shown.

BIN
testing/testing.db Normal file

Binary file not shown.