made non-readonly benchmarks more resilient to OS filesystem cache issues

This commit is contained in:
Joshua Thomas Wise
2018-10-10 12:35:58 -04:00
parent 8051c10f1f
commit 7d5f7ab92a
4 changed files with 23 additions and 29 deletions
+6 -1
View File
@@ -19,8 +19,13 @@ const display = (result) => {
(async () => {
process.on('unhandledRejection', (err) => { throw err; });
const ctx = JSON.parse(process.argv[2]);
const type = require(`./types/${ctx.type}`);
const db = await require('./drivers').get(ctx.driver)('../temp/benchmark.db', ctx.pragma);
const fn = require(`./types/${ctx.type}`)[ctx.driver](db, ctx);
if (!type.readonly) {
for (const table of ctx.tables) await db.exec(`DELETE FROM ${table} WHERE rowid > 1;`);
await db.exec('VACUUM;');
}
const fn = type[ctx.driver](db, ctx);
if (typeof fn === 'function') setImmediate(sync, fn);
else setImmediate(async, await fn);
})();
+1 -2
View File
@@ -15,7 +15,6 @@ const filterBySearchTerms = (searchTerms) => (trial) => {
const terms = [
trial.type,
trial.table,
trial.table.replace('_empty', ''),
`(${trial.columns.join(', ')})`,
`(${trial.columns.join(',')})`,
...trial.columns,
@@ -41,7 +40,7 @@ const displayTrialName = (trial) => {
const createContext = (trial, driver) => {
const { data: _unused, ...tableInfo } = tables.get(trial.table);
return JSON.stringify({ ...trial, ...tableInfo, driver });
return JSON.stringify({ ...trial, ...tableInfo, driver, tables: [...tables.keys()] });
};
const erase = () => {
-10
View File
@@ -8,21 +8,11 @@ const tables = new Map([
data: [null, 0x7fffffff, 1 / 3, 'this is the text', Buffer.from('this is the blob')],
count: 10000,
}],
['small_empty', {
schema: '(nul, integer INTEGER, real REAL, text TEXT, blob BLOB)',
data: [null, 0x7fffffff, 1 / 3, 'this is the text', Buffer.from('this is the blob')],
count: 1,
}],
['large', {
schema: '(text TEXT, blob BLOB)',
data: ['this is the text'.repeat(2048), Buffer.from('this is the blob'.repeat(2048))],
count: 10000,
}],
['large_empty', {
schema: '(text TEXT, blob BLOB)',
data: ['this is the text'.repeat(2048), Buffer.from('this is the blob'.repeat(2048))],
count: 1,
}],
]);
/*
+16 -16
View File
@@ -7,9 +7,9 @@ exports.default = [
description: 'reading 100 rows into an array' },
{ type: 'select-iterate', table: 'small', columns: ['nul', 'integer', 'real', 'text'],
description: 'iterating over 100 rows' },
{ type: 'insert', table: 'small_empty', columns: ['nul', 'integer', 'real', 'text'],
{ type: 'insert', table: 'small', columns: ['nul', 'integer', 'real', 'text'],
description: 'inserting rows individually' },
{ type: 'transaction', table: 'small_empty', columns: ['nul', 'integer', 'real', 'text'],
{ type: 'transaction', table: 'small', columns: ['nul', 'integer', 'real', 'text'],
description: 'inserting 100 rows in a single transaction' },
];
@@ -35,20 +35,20 @@ exports.searchable = [
{ type: 'select-iterate', table: 'small', columns: ['blob'] },
{ type: 'select-iterate', table: 'large', columns: ['text'] },
{ type: 'select-iterate', table: 'large', columns: ['blob'] },
{ type: 'insert', table: 'small_empty', columns: ['nul'] },
{ type: 'insert', table: 'small_empty', columns: ['integer'] },
{ type: 'insert', table: 'small_empty', columns: ['real'] },
{ type: 'insert', table: 'small_empty', columns: ['text'] },
{ type: 'insert', table: 'small_empty', columns: ['blob'] },
{ type: 'insert', table: 'large_empty', columns: ['text'] },
{ type: 'insert', table: 'large_empty', columns: ['blob'] },
{ type: 'transaction', table: 'small_empty', columns: ['nul'] },
{ type: 'transaction', table: 'small_empty', columns: ['integer'] },
{ type: 'transaction', table: 'small_empty', columns: ['real'] },
{ type: 'transaction', table: 'small_empty', columns: ['text'] },
{ type: 'transaction', table: 'small_empty', columns: ['blob'] },
{ type: 'transaction', table: 'large_empty', columns: ['text'] },
{ type: 'transaction', table: 'large_empty', columns: ['blob'] },
{ type: 'insert', table: 'small', columns: ['nul'] },
{ type: 'insert', table: 'small', columns: ['integer'] },
{ type: 'insert', table: 'small', columns: ['real'] },
{ type: 'insert', table: 'small', columns: ['text'] },
{ type: 'insert', table: 'small', columns: ['blob'] },
{ type: 'insert', table: 'large', columns: ['text'] },
{ type: 'insert', table: 'large', columns: ['blob'] },
{ type: 'transaction', table: 'small', columns: ['nul'] },
{ type: 'transaction', table: 'small', columns: ['integer'] },
{ type: 'transaction', table: 'small', columns: ['real'] },
{ type: 'transaction', table: 'small', columns: ['text'] },
{ type: 'transaction', table: 'small', columns: ['blob'] },
{ type: 'transaction', table: 'large', columns: ['text'] },
{ type: 'transaction', table: 'large', columns: ['blob'] },
];
(() => {