mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-17 16:44:19 +01:00
- now, most of the work is happening on the main thread - for database in browser, we still have dedicated WebWorker - but it is used only for OPFS access and only for that - for syn in browser we still offload sync operations to the WebWorker
35 lines
1007 B
JavaScript
35 lines
1007 B
JavaScript
import { run, bench, group, baseline } from 'mitata';
|
|
|
|
import { Database } from '@tursodatabase/database';
|
|
|
|
const db = new Database(':memory:');
|
|
|
|
await db.exec("CREATE TABLE users (id INTEGER, name TEXT, email TEXT)");
|
|
await db.exec("INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.org')");
|
|
|
|
const stmtSelect = db.prepare("SELECT * FROM users WHERE id = ?");
|
|
const rawStmtSelect = db.prepare("SELECT * FROM users WHERE id = ?").raw();
|
|
const stmtInsert = db.prepare("INSERT INTO users (id, name, email) VALUES (?, ?, ?)");
|
|
|
|
bench('Statement.get() with bind parameters [expanded]', async () => {
|
|
await stmtSelect.get(1);
|
|
});
|
|
|
|
bench('Statement.get() with bind parameters [raw]', async () => {
|
|
await rawStmtSelect.get(1);
|
|
});
|
|
|
|
bench('Statement.run() with bind parameters', async () => {
|
|
await stmtInsert.run([1, 'foobar', 'foobar@example.com']);
|
|
});
|
|
|
|
await run({
|
|
units: false,
|
|
silent: false,
|
|
avg: true,
|
|
json: false,
|
|
colors: true,
|
|
min_max: true,
|
|
percentiles: true,
|
|
});
|