Skip to content

Commit 3642945

Browse files
committed
made non-readonly benchmarks more resilient to OS filesystem cache issues
1 parent af65888 commit 3642945

File tree

4 files changed

+23
-29
lines changed

4 files changed

+23
-29
lines changed

benchmark/benchmark.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ const display = (result) => {
1919
(async () => {
2020
process.on('unhandledRejection', (err) => { throw err; });
2121
const ctx = JSON.parse(process.argv[2]);
22+
const type = require(`./types/${ctx.type}`);
2223
const db = await require('./drivers').get(ctx.driver)('../temp/benchmark.db', ctx.pragma);
23-
const fn = require(`./types/${ctx.type}`)[ctx.driver](db, ctx);
24+
if (!type.readonly) {
25+
for (const table of ctx.tables) await db.exec(`DELETE FROM ${table} WHERE rowid > 1;`);
26+
await db.exec('VACUUM;');
27+
}
28+
const fn = type[ctx.driver](db, ctx);
2429
if (typeof fn === 'function') setImmediate(sync, fn);
2530
else setImmediate(async, await fn);
2631
})();

benchmark/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const filterBySearchTerms = (searchTerms) => (trial) => {
1515
const terms = [
1616
trial.type,
1717
trial.table,
18-
trial.table.replace('_empty', ''),
1918
`(${trial.columns.join(', ')})`,
2019
`(${trial.columns.join(',')})`,
2120
...trial.columns,
@@ -41,7 +40,7 @@ const displayTrialName = (trial) => {
4140

4241
const createContext = (trial, driver) => {
4342
const { data: _unused, ...tableInfo } = tables.get(trial.table);
44-
return JSON.stringify({ ...trial, ...tableInfo, driver });
43+
return JSON.stringify({ ...trial, ...tableInfo, driver, tables: [...tables.keys()] });
4544
};
4645

4746
const erase = () => {

benchmark/seed.js

-10
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@ const tables = new Map([
88
data: [null, 0x7fffffff, 1 / 3, 'this is the text', Buffer.from('this is the blob')],
99
count: 10000,
1010
}],
11-
['small_empty', {
12-
schema: '(nul, integer INTEGER, real REAL, text TEXT, blob BLOB)',
13-
data: [null, 0x7fffffff, 1 / 3, 'this is the text', Buffer.from('this is the blob')],
14-
count: 1,
15-
}],
1611
['large', {
1712
schema: '(text TEXT, blob BLOB)',
1813
data: ['this is the text'.repeat(2048), Buffer.from('this is the blob'.repeat(2048))],
1914
count: 10000,
2015
}],
21-
['large_empty', {
22-
schema: '(text TEXT, blob BLOB)',
23-
data: ['this is the text'.repeat(2048), Buffer.from('this is the blob'.repeat(2048))],
24-
count: 1,
25-
}],
2616
]);
2717

2818
/*

benchmark/trials.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ exports.default = [
77
description: 'reading 100 rows into an array' },
88
{ type: 'select-iterate', table: 'small', columns: ['nul', 'integer', 'real', 'text'],
99
description: 'iterating over 100 rows' },
10-
{ type: 'insert', table: 'small_empty', columns: ['nul', 'integer', 'real', 'text'],
10+
{ type: 'insert', table: 'small', columns: ['nul', 'integer', 'real', 'text'],
1111
description: 'inserting rows individually' },
12-
{ type: 'transaction', table: 'small_empty', columns: ['nul', 'integer', 'real', 'text'],
12+
{ type: 'transaction', table: 'small', columns: ['nul', 'integer', 'real', 'text'],
1313
description: 'inserting 100 rows in a single transaction' },
1414
];
1515

@@ -35,20 +35,20 @@ exports.searchable = [
3535
{ type: 'select-iterate', table: 'small', columns: ['blob'] },
3636
{ type: 'select-iterate', table: 'large', columns: ['text'] },
3737
{ type: 'select-iterate', table: 'large', columns: ['blob'] },
38-
{ type: 'insert', table: 'small_empty', columns: ['nul'] },
39-
{ type: 'insert', table: 'small_empty', columns: ['integer'] },
40-
{ type: 'insert', table: 'small_empty', columns: ['real'] },
41-
{ type: 'insert', table: 'small_empty', columns: ['text'] },
42-
{ type: 'insert', table: 'small_empty', columns: ['blob'] },
43-
{ type: 'insert', table: 'large_empty', columns: ['text'] },
44-
{ type: 'insert', table: 'large_empty', columns: ['blob'] },
45-
{ type: 'transaction', table: 'small_empty', columns: ['nul'] },
46-
{ type: 'transaction', table: 'small_empty', columns: ['integer'] },
47-
{ type: 'transaction', table: 'small_empty', columns: ['real'] },
48-
{ type: 'transaction', table: 'small_empty', columns: ['text'] },
49-
{ type: 'transaction', table: 'small_empty', columns: ['blob'] },
50-
{ type: 'transaction', table: 'large_empty', columns: ['text'] },
51-
{ type: 'transaction', table: 'large_empty', columns: ['blob'] },
38+
{ type: 'insert', table: 'small', columns: ['nul'] },
39+
{ type: 'insert', table: 'small', columns: ['integer'] },
40+
{ type: 'insert', table: 'small', columns: ['real'] },
41+
{ type: 'insert', table: 'small', columns: ['text'] },
42+
{ type: 'insert', table: 'small', columns: ['blob'] },
43+
{ type: 'insert', table: 'large', columns: ['text'] },
44+
{ type: 'insert', table: 'large', columns: ['blob'] },
45+
{ type: 'transaction', table: 'small', columns: ['nul'] },
46+
{ type: 'transaction', table: 'small', columns: ['integer'] },
47+
{ type: 'transaction', table: 'small', columns: ['real'] },
48+
{ type: 'transaction', table: 'small', columns: ['text'] },
49+
{ type: 'transaction', table: 'small', columns: ['blob'] },
50+
{ type: 'transaction', table: 'large', columns: ['text'] },
51+
{ type: 'transaction', table: 'large', columns: ['blob'] },
5252
];
5353

5454
(() => {

0 commit comments

Comments
 (0)