Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 482b256

Browse filesBrowse files
araujoguiaduh95
authored andcommitted
benchmark: add SQLite benchmarks
PR-URL: #61401 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 236d7ee commit 482b256
Copy full SHA for 482b256

2 files changed

+101Lines changed: 101 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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: [1e5],
8+
tableSeedSize: [1e5],
9+
statement: [
10+
'SELECT * FROM foo LIMIT 1',
11+
'SELECT * FROM foo LIMIT 100',
12+
],
13+
options: ['none', 'readBigInts', 'returnArrays', 'readBigInts|returnArrays'],
14+
});
15+
16+
function main(conf) {
17+
const optionsObj = conf.options === 'none' ? {} : conf.options.split('|').reduce((acc, key) => {
18+
acc[key] = true;
19+
return acc;
20+
}, {});
21+
22+
const db = new sqlite.DatabaseSync(':memory:', optionsObj);
23+
24+
db.exec(
25+
'CREATE TABLE foo (text_column TEXT, integer_column INTEGER, real_column REAL, blob_column BLOB)',
26+
);
27+
28+
const fooInsertStatement = db.prepare(
29+
'INSERT INTO foo (text_column, integer_column, real_column, blob_column) VALUES (?, ?, ?, ?)',
30+
);
31+
32+
for (let i = 0; i < conf.tableSeedSize; i++) {
33+
fooInsertStatement.run(
34+
crypto.randomUUID(),
35+
Math.floor(Math.random() * 100),
36+
Math.random(),
37+
Buffer.from('example blob data'),
38+
);
39+
}
40+
41+
let i;
42+
let deadCodeElimination;
43+
44+
const stmt = db.prepare(conf.statement);
45+
46+
bench.start();
47+
for (i = 0; i < conf.n; i += 1) deadCodeElimination = stmt.all();
48+
bench.end(conf.n);
49+
50+
assert.ok(deadCodeElimination !== undefined);
51+
}
Collapse file
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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: [1e5],
8+
tableSeedSize: [1e5],
9+
statement: [
10+
'SELECT * FROM foo LIMIT 1',
11+
],
12+
options: ['none', 'readBigInts', 'returnArrays', 'readBigInts|returnArrays'],
13+
});
14+
15+
function main(conf) {
16+
const optionsObj = conf.options === 'none' ? {} : conf.options.split('|').reduce((acc, key) => {
17+
acc[key] = true;
18+
return acc;
19+
}, {});
20+
21+
const db = new sqlite.DatabaseSync(':memory:', optionsObj);
22+
23+
db.exec(
24+
'CREATE TABLE foo (text_column TEXT, integer_column INTEGER, real_column REAL, blob_column BLOB)',
25+
);
26+
27+
const fooInsertStatement = db.prepare(
28+
'INSERT INTO foo (text_column, integer_column, real_column, blob_column) VALUES (?, ?, ?, ?)',
29+
);
30+
31+
for (let i = 0; i < conf.tableSeedSize; i++) {
32+
fooInsertStatement.run(
33+
crypto.randomUUID(),
34+
Math.floor(Math.random() * 100),
35+
Math.random(),
36+
Buffer.from('example blob data'),
37+
);
38+
}
39+
40+
let i;
41+
let deadCodeElimination;
42+
43+
const stmt = db.prepare(conf.statement);
44+
45+
bench.start();
46+
for (i = 0; i < conf.n; i += 1) deadCodeElimination = stmt.get();
47+
bench.end(conf.n);
48+
49+
assert.ok(deadCodeElimination !== undefined);
50+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.