Skip to content

Commit

Permalink
Improve JavaScript benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
penberg committed Jan 5, 2025
1 parent daee7f8 commit ec9031d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
29 changes: 25 additions & 4 deletions bindings/wasm/perf/perf-better-sqlite3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,34 @@ import { run, bench, group, baseline } from 'mitata';

import Database from 'better-sqlite3';

const db = new Database('limbo.db');
const db = new Database('better-sqlite3.db');

const stmt = db.prepare("SELECT 1");
db.exec('CREATE TABLE t (x)');
db.exec('INSERT INTO t VALUES (1)');
db.exec('INSERT INTO t VALUES (2)');
db.exec('INSERT INTO t VALUES (3)');

group('Statement', () => {
group('SQL queries [all()]', () => {
const stmt1 = db.prepare("SELECT 1");
bench('SELECT 1', () => {
stmt.all();
stmt1.all();
});
const stmt2 = db.prepare("SELECT * FROM t");
bench('SELECT * FROM t', () => {
stmt2.all();
});
});

group('SQL queries [iterate()]', () => {
const stmt1 = db.prepare("SELECT 1");
const it1 = stmt1.iterate();
bench('SELECT 1', () => {
it1.next();
});
const stmt2 = db.prepare("SELECT * FROM t");
const it2 = stmt2.iterate();
bench('SELECT * FROM t', () => {
it2.next();
});
});

Expand Down
27 changes: 24 additions & 3 deletions bindings/wasm/perf/perf-limbo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,32 @@ import { Database } from 'limbo-wasm';

const db = new Database('limbo.db');

const stmt = db.prepare("SELECT 1");
db.exec('CREATE TABLE t (x)');
db.exec('INSERT INTO t VALUES (1)');
db.exec('INSERT INTO t VALUES (2)');
db.exec('INSERT INTO t VALUES (3)');

group('Statement', () => {
group('SQL queries [all()]', () => {
const stmt1 = db.prepare("SELECT 1");
bench('SELECT 1', () => {
stmt.all();
stmt1.all();
});
const stmt2 = db.prepare("SELECT * FROM t");
bench('SELECT * FROM t', () => {
stmt2.all();
});
});

group('SQL queries [iterate()]', () => {
const stmt1 = db.prepare("SELECT 1");
const it1 = stmt1.iterate();
bench('SELECT 1', () => {
it1.next();
});
const stmt2 = db.prepare("SELECT * FROM t");
const it2 = stmt2.iterate();
bench('SELECT * FROM t', () => {
it2.next();
});
});

Expand Down

0 comments on commit ec9031d

Please sign in to comment.