Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
sqlite: unify benchmarks
  • Loading branch information
araujogui committed Jan 17, 2026
commit a4fbd763de39c78296f4338b1c2ea5e7b6c2b191
70 changes: 0 additions & 70 deletions benchmark/sqlite/sqlite-prepare-select-all-arrays.js

This file was deleted.

71 changes: 0 additions & 71 deletions benchmark/sqlite/sqlite-prepare-select-all-bigint-arrays.js

This file was deleted.

43 changes: 0 additions & 43 deletions benchmark/sqlite/sqlite-prepare-select-all-bigint.js

This file was deleted.

51 changes: 51 additions & 0 deletions benchmark/sqlite/sqlite-prepare-select-all-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
const common = require('../common.js');
const sqlite = require('node:sqlite');
const assert = require('assert');

const bench = common.createBenchmark(main, {
n: [1e5],
tableSeedSize: [1e5],
statement: [
'SELECT * FROM foo LIMIT 1',
'SELECT * FROM foo LIMIT 100',
],
options: ['none', 'readBigInts', 'returnArrays', 'readBigInts|returnArrays'],
});

function main(conf) {
const optionsObj = conf.options === 'none' ? {} : conf.options.split('|').reduce((acc, key) => {
acc[key] = true;
return acc;
}, {});

const db = new sqlite.DatabaseSync(':memory:', optionsObj);

db.exec(
'CREATE TABLE foo (text_column TEXT, integer_column INTEGER, real_column REAL, blob_column BLOB)',
);

const fooInsertStatement = db.prepare(
'INSERT INTO foo (text_column, integer_column, real_column, blob_column) VALUES (?, ?, ?, ?)',
);

for (let i = 0; i < conf.tableSeedSize; i++) {
fooInsertStatement.run(
crypto.randomUUID(),
Math.floor(Math.random() * 100),
Math.random(),
Buffer.from('example blob data'),
);
}

let i;
let deadCodeElimination;

const stmt = db.prepare(conf.statement);

bench.start();
for (i = 0; i < conf.n; i += 1) deadCodeElimination = stmt.all();
bench.end(conf.n);

assert.ok(deadCodeElimination !== undefined);
}
50 changes: 50 additions & 0 deletions benchmark/sqlite/sqlite-prepare-select-get-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict';
const common = require('../common.js');
const sqlite = require('node:sqlite');
const assert = require('assert');

const bench = common.createBenchmark(main, {
n: [1e5],
tableSeedSize: [1e5],
statement: [
'SELECT * FROM foo LIMIT 1',
],
options: ['none', 'readBigInts', 'returnArrays', 'readBigInts|returnArrays'],
});

function main(conf) {
const optionsObj = conf.options === 'none' ? {} : conf.options.split('|').reduce((acc, key) => {
acc[key] = true;
return acc;
}, {});

const db = new sqlite.DatabaseSync(':memory:', optionsObj);

db.exec(
'CREATE TABLE foo (text_column TEXT, integer_column INTEGER, real_column REAL, blob_column BLOB)',
);

const fooInsertStatement = db.prepare(
'INSERT INTO foo (text_column, integer_column, real_column, blob_column) VALUES (?, ?, ?, ?)',
);

for (let i = 0; i < conf.tableSeedSize; i++) {
fooInsertStatement.run(
crypto.randomUUID(),
Math.floor(Math.random() * 100),
Math.random(),
Buffer.from('example blob data'),
);
}

let i;
let deadCodeElimination;

const stmt = db.prepare(conf.statement);

bench.start();
for (i = 0; i < conf.n; i += 1) deadCodeElimination = stmt.get();
bench.end(conf.n);

assert.ok(deadCodeElimination !== undefined);
}
Loading