Files
node/benchmark/sqlite/sqlite-prepare-select-get-options.js
Guilherme Araújo f2b698f1cf sqlite: rename DatabaseSync and StatementSync
Rename the DatabaseSync and StatementSync classes to Database and
Statement, and the internal DatabaseSyncLimits helper to
DatabaseLimits. The old names are kept as aliases of the new classes
and are Documentation-only deprecated (DEP0210, DEP0211).

Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65988
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-09-26 00:03:45 +00:00

51 lines
1.3 KiB
JavaScript

'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.Database(':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);
}