mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-19 09:34:18 +01:00
bindings/javascript: Add INSERT benchmark too
This commit is contained in:
@@ -4,21 +4,24 @@ import Database from 'better-sqlite3';
|
||||
|
||||
const db = new Database(':memory:');
|
||||
|
||||
db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)");
|
||||
db.exec("CREATE TABLE users (id INTEGER, name TEXT, email TEXT)");
|
||||
db.exec("INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.org')");
|
||||
|
||||
const stmt = db.prepare("SELECT * FROM users WHERE id = ?");
|
||||
const rawStmt = db.prepare("SELECT * FROM users WHERE id = ?").raw();
|
||||
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 (?, ?, ?)");
|
||||
|
||||
group('Statement', () => {
|
||||
bench('Statement.get() with bind parameters [expanded]', () => {
|
||||
stmt.get(1);
|
||||
});
|
||||
bench('Statement.get() with bind parameters [raw]', () => {
|
||||
rawStmt.get(1);
|
||||
});
|
||||
bench('Statement.get() with bind parameters [expanded]', () => {
|
||||
stmtSelect.get(1);
|
||||
});
|
||||
|
||||
bench('Statement.git() with bind parameters [raw]', () => {
|
||||
rawStmtSelect.get(1);
|
||||
});
|
||||
|
||||
bench('Statement.run() with bind parameters', () => {
|
||||
stmtInsert.run([1, 'foobar', 'foobar@example.com']);
|
||||
});
|
||||
|
||||
await run({
|
||||
units: false,
|
||||
|
||||
Reference in New Issue
Block a user