-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicron-cli.js
executable file
·101 lines (98 loc) · 2.81 KB
/
micron-cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env node
'use strict';
const Micron = require('./micron');
const commandLineArgs = require('command-line-args');
const commandLineUsage = require('command-line-usage');
const chalk = require('chalk');
const header = require('./assets/header');
const optionDefinitions = [
{name: 'folder', defaultOption: true, type: String},
{name: 'start', alias: 's', type: Number},
{name: 'end', alias: 'e', type: Number},
{name: 'step', alias: 'i', type: Number},
{name: 'repeats', alias: 'r', type: Number},
{name: 'verbose', alias: 'v', type: Boolean},
{name: 'outdir', alias: 'o', type: String},
{name: 'help', alias: 'h', type: Boolean}
];
const sections = [
{
content: chalk.green(header),
raw: true
},
{
header: 'Micron - benchmark runner',
content: [
'Run your performance benchmark easier than ever.'
]
},
{
header: 'Options',
optionList: [
{
name: 'folder',
typeLabel: '{underline dir}',
defaultOption: true,
description: 'The input folder.'
},
{
name: 'start',
typeLabel: '{underline integer}',
description: 'Initial amount of executions in the loop.'
},
{
name: 'end',
typeLabel: '{underline integer}',
description: 'End amount of executions in the loop.'
},
{
name: 'step',
typeLabel: '{underline integer}',
defaultOption: true,
description: 'Step from start to end.'
},
{
name: 'repeats',
typeLabel: '{underline integer}',
defaultOption: true,
description: 'Reapets for each loop.'
},
{
name: 'outdir',
typeLabel: '{underline path}',
defaultOption: true,
description: 'Outdir for save results.'
},
{
name: 'help',
description: 'Print this usage guide.'
}
]
},
{
header: 'Examples',
content:[
{colA: 'Basic Example:', colB: '$ micron test'},
{colA: 'With Args:', colB: '$ micron test --start 200 --end 2200 --step 500 -r 3'}
]
}
];
const usage = commandLineUsage(sections);
let options;
try {
options = commandLineArgs(optionDefinitions);
if(options.help) {
console.log(usage);
return;
}
} catch (e) {
console.log(usage);
return;
}
const runner = new Micron(options);
runner
.run()
.catch((error) => {
console.log(usage);
console.error('MicronError: ', error);
});