mirror of https://github.com/nodejs/node.git
benchmark: add sqlite is transaction
PR-URL: https://github.com/nodejs/node/pull/58040 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
This commit is contained in:
parent
743fba59c8
commit
013d3264a4
|
@ -0,0 +1,31 @@
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common.js');
|
||||||
|
const sqlite = require('node:sqlite');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const bench = common.createBenchmark(main, {
|
||||||
|
n: [1e7],
|
||||||
|
transaction: ['true', 'false'],
|
||||||
|
});
|
||||||
|
|
||||||
|
function main(conf) {
|
||||||
|
const db = new sqlite.DatabaseSync(':memory:');
|
||||||
|
|
||||||
|
if (conf.transaction === 'true') {
|
||||||
|
db.exec('BEGIN');
|
||||||
|
}
|
||||||
|
|
||||||
|
let i;
|
||||||
|
let deadCodeElimination;
|
||||||
|
|
||||||
|
bench.start();
|
||||||
|
for (i = 0; i < conf.n; i += 1)
|
||||||
|
deadCodeElimination &&= db.isTransaction;
|
||||||
|
bench.end(conf.n);
|
||||||
|
|
||||||
|
assert.ok(deadCodeElimination === (conf.transaction === 'true'));
|
||||||
|
|
||||||
|
if (conf.transaction === 'true') {
|
||||||
|
db.exec('ROLLBACK');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue