@@ -24,6 +24,14 @@ const filterBySearchTerms = (searchTerms) => (trial) => {
24
24
return searchTerms . every ( arg => terms . includes ( arg ) ) ;
25
25
} ;
26
26
27
+ const sortTrials = ( a , b ) => {
28
+ const aRo = require ( `./types/${ a . type } ` ) . readonly ;
29
+ const bRo = require ( `./types/${ b . type } ` ) . readonly ;
30
+ if ( typeof aRo !== 'boolean' ) throw new TypeError ( `Missing readonly export in benchmark type ${ a . type } ` ) ;
31
+ if ( typeof bRo !== 'boolean' ) throw new TypeError ( `Missing readonly export in benchmark type ${ b . type } ` ) ;
32
+ return bRo - aRo ;
33
+ } ;
34
+
27
35
const displayTrialName = ( trial ) => {
28
36
if ( trial . description ) return console . log ( clc . magenta ( `--- ${ trial . description } ---` ) ) ;
29
37
const name = `${ trial . type } ${ trial . table } (${ trial . columns . join ( ', ' ) } )` ;
@@ -33,8 +41,7 @@ const displayTrialName = (trial) => {
33
41
34
42
const createContext = ( trial , driver ) => {
35
43
const { data : _unused , ...tableInfo } = tables . get ( trial . table ) ;
36
- const ctx = { ...trial , ...tableInfo , driver, filename : `../temp/${ iteration ++ } .db` } ;
37
- return JSON . stringify ( ctx ) ;
44
+ return JSON . stringify ( { ...trial , ...tableInfo , driver } ) ;
38
45
} ;
39
46
40
47
const erase = ( ) => {
@@ -43,20 +50,19 @@ const erase = () => {
43
50
44
51
// Determine which trials should be executed.
45
52
process . chdir ( __dirname ) ;
46
- const trials = getTrials ( process . argv . slice ( 2 ) ) ;
53
+ const trials = getTrials ( process . argv . slice ( 2 ) ) . sort ( sortTrials ) ;
47
54
if ( ! trials . length ) {
48
55
console . log ( clc . yellow ( 'No matching benchmarks found!' ) ) ;
49
56
process . exit ( ) ;
50
57
}
51
58
52
- // Create the temporary databases needed to run the benchmark trials.
59
+ // Create the temporary database needed to run the benchmark trials.
53
60
console . log ( 'Generating tables...' ) ;
54
- const drivers = require ( './drivers' ) ;
55
- const tables = require ( './seed' ) ( drivers . size * trials . length ) ;
61
+ const tables = require ( './seed' ) ( ) ;
56
62
process . stdout . write ( erase ( ) ) ;
57
63
58
64
// Execute each trial for each available driver.
59
- let iteration = 0 ;
65
+ const drivers = require ( './drivers' ) ;
60
66
const nameLength = [ ...drivers . keys ( ) ] . reduce ( ( m , d ) => Math . max ( m , d . length ) , 0 ) ;
61
67
for ( const trial of trials ) {
62
68
displayTrialName ( trial ) ;
0 commit comments