This repository has been archived by the owner on Nov 10, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfoxify-benchmarks-bench.js
77 lines (73 loc) · 1.64 KB
/
foxify-benchmarks-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
74
75
76
77
#!/usr/bin/env node
"use strict"
const inquirer = require("inquirer")
const bench = require("./lib/bench")
const { choices, list } = require("./lib/packages")
function select(callback) {
inquirer.prompt([
{
type: "checkbox",
message: "Select packages",
name: "list",
choices: [
new inquirer.Separator(" = The usual ="),
...list(),
new inquirer.Separator(" = The extras = "),
...list(true)
],
validate: function (answer) {
if (answer.length < 1) {
return "You must choose at least one package."
}
return true
}
}
])
.then(function (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: 100,
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: 10,
validate(value) {
return !Number.isNaN(parseFloat(value)) || "Please enter a number"
},
filter: Number
},
{
type: "input",
name: "duration",
message: "How long should it take?",
default: 5,
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)
}
})