mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
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>
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
const sqlite = require('node:sqlite');
|
|
const dc = require('node:diagnostics_channel');
|
|
const assert = require('node:assert');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e5],
|
|
mode: ['none', 'subscribed', 'unsubscribed'],
|
|
});
|
|
|
|
function main(conf) {
|
|
const { n, mode } = conf;
|
|
|
|
const db = new sqlite.Database(':memory:');
|
|
db.exec('CREATE TABLE t (x INTEGER)');
|
|
const insert = db.prepare('INSERT INTO t VALUES (?)');
|
|
|
|
let subscriber;
|
|
if (mode === 'subscribed') {
|
|
subscriber = () => {};
|
|
dc.subscribe('sqlite.db.query', subscriber);
|
|
} else if (mode === 'unsubscribed') {
|
|
subscriber = () => {};
|
|
dc.subscribe('sqlite.db.query', subscriber);
|
|
dc.unsubscribe('sqlite.db.query', subscriber);
|
|
}
|
|
// mode === 'none': no subscription ever made
|
|
|
|
let result;
|
|
bench.start();
|
|
for (let i = 0; i < n; i++) {
|
|
result = insert.run(i);
|
|
}
|
|
bench.end(n);
|
|
|
|
if (mode === 'subscribed') {
|
|
dc.unsubscribe('sqlite.db.query', subscriber);
|
|
}
|
|
|
|
assert.ok(result !== undefined);
|
|
}
|