-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabrunner.js
executable file
·59 lines (50 loc) · 2.16 KB
/
abrunner.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
#!/usr/bin/env node
const { Command, Option } = require('commander');
const { Compare } = require('./src/compare');
const { Measure } = require('./src/measure');
/**
* Measure (run Apache Benchmark)
*/
const measure = new Command('measure');
measure
.addOption(new Option('-o, --output-dir <string>', 'directory to store output').makeOptionMandatory())
.addOption(new Option('-r, --requests <int>', 'number of requests to make to url').default(500))
.addOption(new Option('-c, --concurrency <int>', 'number of concurrent requests').default(10))
.addOption(new Option('-u, --url <string>', 'url to test').makeOptionMandatory())
.addOption(new Option('-m, --method <string>', 'GET, POST, PUT, HEAD, etc').default('GET'))
.addOption(new Option('-t, --content-type <string>', 'Content-Type header for POST/PUT requests'))
.addOption(new Option('-h, --headers <string...>', 'One or more headers to add to the request, eg. \'Accept-Encoding: gzip\''))
.addOption(new Option('-i, --iterations <int>', 'how often should the measurement be repeated').default(10))
.addOption(new Option('-w, --wait <int>', 'how long to wait between iterations (in seconds)').default(300, '5 minutes'))
.action((options) => {
try {
const measure = new Measure(options);
measure.run();
} catch (error) {
console.error(error)
}
})
/**
* Compare
*/
const compare = new Command('compare');
compare
.addOption(new Option('-i, --input-files <string...>', 'input files to compare').makeOptionMandatory())
.addOption(new Option('-l, --labels <string...>', 'label for each directory (used in plot)').makeOptionMandatory())
.addOption(new Option('-o, --output-dir <string>', 'directory to store output').makeOptionMandatory())
.action((options) => {
try {
const compare = new Compare(options);
compare.run();
} catch (error) {
console.error(error)
}
})
/**
* Main
*/
program = new Command();
program.showHelpAfterError('(add --help for additional information)');
program.addCommand(measure);
program.addCommand(compare);
program.parse(process.argv);