mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
Use larger and more realistic database for testing
This commit is contained in:
parent
4d8e0f1214
commit
cc101b1b00
6 changed files with 41 additions and 5 deletions
|
@ -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! {
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
BIN
testing/hello.db
BIN
testing/hello.db
Binary file not shown.
BIN
testing/testing.db
Normal file
BIN
testing/testing.db
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue