Skip to content

Commit 8b2f124

Browse files
committed
upgrade dependencies
1 parent fa937a7 commit 8b2f124

File tree

9 files changed

+949
-1157
lines changed

9 files changed

+949
-1157
lines changed

.eslintrc.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
4+
export default [
5+
{
6+
ignores: ['node_modules/', 'build/', 'prebuilds/', 'deps/'],
7+
},
8+
{
9+
files: ['**/*.js'],
10+
languageOptions: {
11+
ecmaVersion: 2020,
12+
sourceType: 'module',
13+
globals: {
14+
...globals.node,
15+
},
16+
},
17+
rules: {
18+
...js.configs.recommended.rules,
19+
'indent': ['error', 4],
20+
'linebreak-style': ['error', 'unix'],
21+
'semi': ['error', 'always'],
22+
'no-cond-assign': ['error', 'always'],
23+
'no-inner-declarations': 'off',
24+
},
25+
},
26+
{
27+
files: ['test/**/*.js'],
28+
languageOptions: {
29+
globals: {
30+
...globals.mocha,
31+
},
32+
},
33+
rules: {
34+
'no-unused-vars': 'off',
35+
},
36+
},
37+
{
38+
files: ['tools/**/*.js'],
39+
rules: {
40+
'no-unused-vars': 'off',
41+
},
42+
},
43+
];

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@
4545
},
4646
"dependencies": {
4747
"bindings": "^1.5.0",
48-
"node-addon-api": "^8.0.0",
48+
"node-addon-api": "^8.7.0",
4949
"prebuild-install": "^7.1.3",
50-
"tar": "^7.5.10"
50+
"tar": "^7.5.13"
5151
},
5252
"devDependencies": {
53-
"eslint": "8.56.0",
54-
"mocha": "10.2.0",
53+
"@eslint/js": "^10.0.1",
54+
"eslint": "^10.2.0",
55+
"globals": "^17.4.0",
56+
"mocha": "11.7.5",
5557
"nyc": "^18.0.0",
5658
"prebuild": "13.0.1",
57-
"tinybench": "^2.9.0"
59+
"tinybench": "^6.0.0"
5860
},
5961
"peerDependencies": {
6062
"node-gyp": "12.x"
@@ -76,7 +78,7 @@
7678
"rebuild": "node-gyp rebuild",
7779
"upload": "prebuild --verbose --prerelease",
7880
"frozen-install": "yarn install --frozen-lockfile",
79-
"lint": "eslint .eslintrc.js lib/ test/ tools/",
81+
"lint": "eslint lib/ test/ tools/",
8082
"test": "node test/support/createdb.js && nyc mocha -R spec --timeout 480000"
8183
},
8284
"license": "BSD-3-Clause",

test/.eslintrc.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

tools/.eslintrc.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

tools/benchmark/insert.js

Lines changed: 122 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -40,121 +40,132 @@ function promisifyClose(db) {
4040
*/
4141
module.exports = {
4242
benchmarks: {
43-
'literal file': {
44-
async beforeEach() {
45-
// Setup: Create in-memory database - NOT measured
46-
this.db = new sqlite3.Database(':memory:');
47-
this.sqlFile = fs.readFileSync(__dirname + '/insert-transaction.sql', 'utf8');
48-
},
49-
50-
async fn() {
51-
// Benchmark: Execute SQL file - MEASURED
52-
await promisifyExec(this.db, this.sqlFile);
53-
},
54-
55-
async afterEach() {
56-
// Teardown: Close database - NOT measured
57-
await promisifyClose(this.db);
58-
},
59-
},
60-
61-
'transaction with two statements': {
62-
async beforeEach() {
63-
// Setup: Create database and table - NOT measured
64-
this.db = new sqlite3.Database(':memory:');
65-
await promisifyRun(this.db, 'CREATE TABLE foo (id INT, txt TEXT)');
66-
},
67-
68-
async fn() {
69-
// Benchmark: Insert with transaction and two parallel statements - MEASURED
70-
const db = this.db;
71-
72-
await new Promise((resolve, reject) => {
73-
db.serialize(async () => {
74-
await promisifyRun(db, 'BEGIN');
75-
76-
db.parallelize(() => {
77-
const stmt1 = db.prepare('INSERT INTO foo VALUES (?, ?)');
78-
const stmt2 = db.prepare('INSERT INTO foo VALUES (?, ?)');
43+
'literal file': (() => {
44+
let db = null;
45+
let sqlFile = null;
46+
47+
return {
48+
async beforeEach() {
49+
// Setup: Create in-memory database - NOT measured
50+
db = new sqlite3.Database(':memory:');
51+
sqlFile = fs.readFileSync(__dirname + '/insert-transaction.sql', 'utf8');
52+
},
53+
54+
async fn() {
55+
// Benchmark: Execute SQL file - MEASURED
56+
await promisifyExec(db, sqlFile);
57+
},
58+
59+
async afterEach() {
60+
// Teardown: Close database - NOT measured
61+
await promisifyClose(db);
62+
},
63+
};
64+
})(),
65+
66+
'transaction with two statements': (() => {
67+
let db = null;
68+
69+
return {
70+
async beforeEach() {
71+
// Setup: Create database and table - NOT measured
72+
db = new sqlite3.Database(':memory:');
73+
await promisifyRun(db, 'CREATE TABLE foo (id INT, txt TEXT)');
74+
},
75+
76+
async fn() {
77+
// Benchmark: Insert with transaction and two parallel statements - MEASURED
78+
await new Promise((resolve, reject) => {
79+
db.serialize(async () => {
80+
await promisifyRun(db, 'BEGIN');
81+
82+
db.parallelize(() => {
83+
const stmt1 = db.prepare('INSERT INTO foo VALUES (?, ?)');
84+
const stmt2 = db.prepare('INSERT INTO foo VALUES (?, ?)');
85+
for (let i = 0; i < iterations; i++) {
86+
stmt1.run(i, 'Row ' + i);
87+
i++;
88+
stmt2.run(i, 'Row ' + i);
89+
}
90+
stmt1.finalize();
91+
stmt2.finalize();
92+
});
93+
94+
await promisifyRun(db, 'COMMIT');
95+
resolve();
96+
});
97+
});
98+
},
99+
100+
async afterEach() {
101+
// Teardown: Close database - NOT measured
102+
await promisifyClose(db);
103+
},
104+
};
105+
})(),
106+
107+
'with transaction': (() => {
108+
let db = null;
109+
110+
return {
111+
async beforeEach() {
112+
// Setup: Create database and table - NOT measured
113+
db = new sqlite3.Database(':memory:');
114+
await promisifyRun(db, 'CREATE TABLE foo (id INT, txt TEXT)');
115+
},
116+
117+
async fn() {
118+
// Benchmark: Insert with transaction - MEASURED
119+
await new Promise((resolve, reject) => {
120+
db.serialize(async () => {
121+
await promisifyRun(db, 'BEGIN');
122+
const stmt = db.prepare('INSERT INTO foo VALUES (?, ?)');
79123
for (let i = 0; i < iterations; i++) {
80-
stmt1.run(i, 'Row ' + i);
81-
i++;
82-
stmt2.run(i, 'Row ' + i);
124+
stmt.run(i, 'Row ' + i);
83125
}
84-
stmt1.finalize();
85-
stmt2.finalize();
126+
stmt.finalize();
127+
await promisifyRun(db, 'COMMIT');
128+
resolve();
86129
});
87-
88-
await promisifyRun(db, 'COMMIT');
89-
resolve();
90-
});
91-
});
92-
},
93-
94-
async afterEach() {
95-
// Teardown: Close database - NOT measured
96-
await promisifyClose(this.db);
97-
},
98-
},
99-
100-
'with transaction': {
101-
async beforeEach() {
102-
// Setup: Create database and table - NOT measured
103-
this.db = new sqlite3.Database(':memory:');
104-
await promisifyRun(this.db, 'CREATE TABLE foo (id INT, txt TEXT)');
105-
},
106-
107-
async fn() {
108-
// Benchmark: Insert with transaction - MEASURED
109-
const db = this.db;
110-
111-
await new Promise((resolve, reject) => {
112-
db.serialize(async () => {
113-
await promisifyRun(db, 'BEGIN');
114-
const stmt = db.prepare('INSERT INTO foo VALUES (?, ?)');
115-
for (let i = 0; i < iterations; i++) {
116-
stmt.run(i, 'Row ' + i);
117-
}
118-
stmt.finalize();
119-
await promisifyRun(db, 'COMMIT');
120-
resolve();
121130
});
122-
});
123-
},
124-
125-
async afterEach() {
126-
// Teardown: Close database - NOT measured
127-
await promisifyClose(this.db);
128-
},
129-
},
130-
131-
'without transaction': {
132-
async beforeEach() {
133-
// Setup: Create database and table - NOT measured
134-
this.db = new sqlite3.Database(':memory:');
135-
await promisifyRun(this.db, 'CREATE TABLE foo (id INT, txt TEXT)');
136-
},
137-
138-
async fn() {
139-
// Benchmark: Insert without transaction - MEASURED
140-
const db = this.db;
141-
142-
await new Promise((resolve, reject) => {
143-
db.serialize(() => {
144-
const stmt = db.prepare('INSERT INTO foo VALUES (?, ?)');
145-
for (let i = 0; i < iterations; i++) {
146-
stmt.run(i, 'Row ' + i);
147-
}
148-
stmt.finalize();
149-
resolve();
131+
},
132+
133+
async afterEach() {
134+
// Teardown: Close database - NOT measured
135+
await promisifyClose(db);
136+
},
137+
};
138+
})(),
139+
140+
'without transaction': (() => {
141+
let db = null;
142+
143+
return {
144+
async beforeEach() {
145+
// Setup: Create database and table - NOT measured
146+
db = new sqlite3.Database(':memory:');
147+
await promisifyRun(db, 'CREATE TABLE foo (id INT, txt TEXT)');
148+
},
149+
150+
async fn() {
151+
// Benchmark: Insert without transaction - MEASURED
152+
await new Promise((resolve, reject) => {
153+
db.serialize(() => {
154+
const stmt = db.prepare('INSERT INTO foo VALUES (?, ?)');
155+
for (let i = 0; i < iterations; i++) {
156+
stmt.run(i, 'Row ' + i);
157+
}
158+
stmt.finalize();
159+
resolve();
160+
});
150161
});
151-
});
152-
},
153-
154-
async afterEach() {
155-
// Teardown: Close database - NOT measured
156-
await promisifyClose(this.db);
157-
},
158-
},
162+
},
163+
164+
async afterEach() {
165+
// Teardown: Close database - NOT measured
166+
await promisifyClose(db);
167+
},
168+
};
169+
})(),
159170
},
160171
};

tools/benchmark/run.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ async function runBenchmarks() {
3030
console.log('=== SELECT BENCHMARKS ===\n');
3131
for (const [name, benchmark] of Object.entries(selectBenchmarks.benchmarks)) {
3232
suite.add(`select: ${name}`, benchmark.fn, {
33-
beforeEach: benchmark.beforeEach,
34-
afterEach: benchmark.afterEach,
33+
beforeAll: benchmark.beforeAll,
34+
afterAll: benchmark.afterAll,
3535
});
3636
}
3737

@@ -54,9 +54,10 @@ async function runBenchmarks() {
5454

5555
// Results
5656
for (const task of suite.tasks) {
57-
if (task.result && !task.result.error) {
57+
if (task.result && task.result.samples && task.result.samples.length > 0) {
58+
// tinybench v6: result has hz (ops/sec), mean (ms), rme (relative margin of error)
5859
const opsSec = task.result.hz.toFixed(2);
59-
const avgTime = (task.result.mean * 1e9).toFixed(2);
60+
const avgTime = (task.result.mean * 1e6).toFixed(2); // Convert ms to nanoseconds
6061
const margin = task.result.rme.toFixed(2);
6162
const samples = task.result.samples.length;
6263

@@ -70,6 +71,8 @@ async function runBenchmarks() {
7071
console.log(row);
7172
} else if (task.result?.error) {
7273
console.log(`${task.name.padEnd(45)} ERROR: ${task.result.error.message}`);
74+
} else {
75+
console.log(`${task.name.padEnd(45)} No results`);
7376
}
7477
}
7578
}

0 commit comments

Comments
 (0)