Files
turso/bindings/javascript/perf/perf-turso.js
Nikita Sivukhin 974feac27b move compute to the main thread for browser and node
- 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
2025-09-19 13:19:30 +04:00

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,
});