We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d7a43b commit a774b05Copy full SHA for a774b05
benchmark/sqlite/sqlite-is-transaction.js
@@ -0,0 +1,31 @@
1
+'use strict';
2
+const common = require('../common.js');
3
+const sqlite = require('node:sqlite');
4
+const assert = require('assert');
5
+
6
+const bench = common.createBenchmark(main, {
7
+ n: [1e7],
8
+ transaction: ['true', 'false'],
9
+});
10
11
+function main(conf) {
12
+ const db = new sqlite.DatabaseSync(':memory:');
13
14
+ if (conf.transaction === 'true') {
15
+ db.exec('BEGIN');
16
+ }
17
18
+ let i;
19
+ let deadCodeElimination;
20
21
+ bench.start();
22
+ for (i = 0; i < conf.n; i += 1)
23
+ deadCodeElimination &&= db.isTransaction;
24
+ bench.end(conf.n);
25
26
+ assert.ok(deadCodeElimination === (conf.transaction === 'true'));
27
28
29
+ db.exec('ROLLBACK');
30
31
+}
0 commit comments