@browserless/benchmark 9.2.10 → 9.3.14-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/src/flags.js +2 -2
- package/src/index.js +3 -27
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@browserless/benchmark",
|
|
3
3
|
"description": "Benchmarking tool for testing different browserless configurations",
|
|
4
4
|
"homepage": "https://browserless.js.org/#/?id=benchmark",
|
|
5
|
-
"version": "9.
|
|
5
|
+
"version": "9.3.14-alpha.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "josefrancisco.verdu@gmail.com",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"puppeteer"
|
|
30
30
|
],
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@browserless/pool": "latest",
|
|
33
32
|
"asciichart": "latest",
|
|
34
33
|
"browserless": "latest",
|
|
35
34
|
"debug-logfmt": "latest",
|
|
@@ -59,5 +58,5 @@
|
|
|
59
58
|
"test": "exit 0"
|
|
60
59
|
},
|
|
61
60
|
"license": "MIT",
|
|
62
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "fe55af014debe242ee3823464a5e760afafca821"
|
|
63
62
|
}
|
package/src/flags.js
CHANGED
package/src/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
process.setMaxListeners(Infinity)
|
|
4
4
|
|
|
5
5
|
const createBrowserless = require('browserless')
|
|
6
|
-
const createBrowserlessPool = require('@browserless/pool')
|
|
7
6
|
const { includes, reduce } = require('lodash')
|
|
8
7
|
const processStats = require('process-stats')
|
|
9
8
|
const asciichart = require('asciichart')
|
|
@@ -20,10 +19,7 @@ const cli = meow(
|
|
|
20
19
|
|
|
21
20
|
Flags
|
|
22
21
|
--method Choose what method to run (html, text, pdf, screenshot).
|
|
23
|
-
--pool Enable pool mode.
|
|
24
22
|
--iterations Number of iterations.
|
|
25
|
-
--pool-min Mininum of instances in pool mode.
|
|
26
|
-
--pool-max Maximum of instances in pool mode.
|
|
27
23
|
--concurrency Define number of concurrent request.
|
|
28
24
|
--firefox Use Firefox browser.
|
|
29
25
|
|
|
@@ -56,14 +52,7 @@ const cli = meow(
|
|
|
56
52
|
}
|
|
57
53
|
)
|
|
58
54
|
|
|
59
|
-
const benchmark = async ({
|
|
60
|
-
createBrowserless,
|
|
61
|
-
method,
|
|
62
|
-
url,
|
|
63
|
-
opts,
|
|
64
|
-
iterations,
|
|
65
|
-
concurrency
|
|
66
|
-
}) => {
|
|
55
|
+
const benchmark = async ({ createBrowserless, method, url, opts, iterations, concurrency }) => {
|
|
67
56
|
const timer = new Measured.Timer()
|
|
68
57
|
const promises = [...Array(iterations).keys()].map(n => {
|
|
69
58
|
return async () => {
|
|
@@ -105,23 +94,11 @@ const main = async () => {
|
|
|
105
94
|
|
|
106
95
|
if (!method) throw new TypeError('Need to provide a method to run.')
|
|
107
96
|
|
|
108
|
-
const puppeteer = firefox
|
|
109
|
-
? require('puppeteer-firefox')
|
|
110
|
-
: require('puppeteer')
|
|
111
|
-
|
|
112
|
-
const _createBrowserless = isPool
|
|
113
|
-
? () =>
|
|
114
|
-
createBrowserlessPool({
|
|
115
|
-
min: poolMin,
|
|
116
|
-
max: poolMax,
|
|
117
|
-
puppeteer,
|
|
118
|
-
...opts
|
|
119
|
-
})
|
|
120
|
-
: () => createBrowserless({ puppeteer, ...opts })
|
|
97
|
+
const puppeteer = firefox ? require('puppeteer-firefox') : require('puppeteer')
|
|
121
98
|
|
|
122
99
|
const { times, histogram } = await benchmark({
|
|
123
100
|
concurrency,
|
|
124
|
-
createBrowserless:
|
|
101
|
+
createBrowserless: createBrowserless({ puppeteer, ...opts }),
|
|
125
102
|
iterations,
|
|
126
103
|
method,
|
|
127
104
|
url,
|
|
@@ -132,7 +109,6 @@ const main = async () => {
|
|
|
132
109
|
histogram,
|
|
133
110
|
(acc, value, key) => {
|
|
134
111
|
const newValue = !includes(['count'], key) ? prettyMs(value) : value
|
|
135
|
-
|
|
136
112
|
return { ...acc, [key]: newValue }
|
|
137
113
|
},
|
|
138
114
|
{}
|