forked from benawad/node-graphql-benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark-bench.js
73 lines (70 loc) · 1.63 KB
/
benchmark-bench.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
#!/usr/bin/env node
const inquirer = require("inquirer");
const bench = require("./lib/bench");
const { choices } = require("./lib/choices");
function select(callback) {
inquirer
.prompt([
{
type: "checkbox",
message: "Select packages",
name: "list",
choices: [...choices.map((name) => ({ name }))],
validate(answer) {
if (answer.length < 1) {
return "You must choose at least one package.";
}
return true;
},
},
])
.then((answers) => {
callback(answers.list);
});
}
inquirer
.prompt([
{
type: "confirm",
name: "all",
message: "Do you want to run all benchmark tests?",
default: false,
},
{
type: "input",
name: "connections",
message: "How many connections do you need?",
default: 10,
validate(value) {
return !Number.isNaN(parseFloat(value)) || "Please enter a number";
},
filter: Number,
},
{
type: "input",
name: "pipelining",
message: "How many pipelines do you need?",
default: 1,
validate(value) {
return !Number.isNaN(parseFloat(value)) || "Please enter a number";
},
filter: Number,
},
{
type: "input",
name: "duration",
message: "How long should it take?",
default: 15,
validate(value) {
return !Number.isNaN(parseFloat(value)) || "Please enter a number";
},
filter: Number,
},
])
.then((opts) => {
if (!opts.all) {
select((list) => bench(opts, list));
} else {
bench(opts, choices);
}
});