@browserless/benchmark 9.6.2 → 9.7.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 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.6.2",
5
+ "version": "9.7.0",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "josefrancisco.verdu@gmail.com",
@@ -57,5 +57,5 @@
57
57
  "test": "exit 0"
58
58
  },
59
59
  "license": "MIT",
60
- "gitHead": "e29ac9d5b86e7db27429130abc9689bbf39025dd"
60
+ "gitHead": "4da0a992dd779d5b7a6cc8a0bb8f9e918808f6e1"
61
61
  }
package/src/index.js CHANGED
@@ -58,9 +58,9 @@ const getStrategy = opts => {
58
58
  context: () => {
59
59
  return {
60
60
  onInit: () => createBrowserless(opts),
61
- onCreate: browserlessFactory => browserlessFactory.createContext(),
61
+ onCreate: browser => browser.createContext(),
62
62
  onDestroy: browserless => browserless.destroyContext(),
63
- onClose: browserlessFactory => browserlessFactory.close()
63
+ onClose: browser => browser.close()
64
64
  }
65
65
  },
66
66
  process: () => {
@@ -68,14 +68,14 @@ const getStrategy = opts => {
68
68
  return {
69
69
  onInit: () => {},
70
70
  onCreate: (_, n) => {
71
- const browserlessFactory = createBrowserless(opts)
72
- browsers.set(n, browserlessFactory)
73
- return browserlessFactory.createContext()
71
+ const browser = createBrowserless(opts)
72
+ browsers.set(n, browser)
73
+ return browser.createContext()
74
74
  },
75
75
  onDestroy: async (browserless, n) => {
76
- const browserlessFactory = browsers.get(n)
76
+ const browser = browsers.get(n)
77
77
  await browserless.destroyContext()
78
- return browserlessFactory.close()
78
+ return browser.close()
79
79
  },
80
80
  onClose: () => {}
81
81
  }
@@ -85,7 +85,7 @@ const getStrategy = opts => {
85
85
 
86
86
  const benchmark = async ({
87
87
  strategy,
88
- browserlessFactory,
88
+ browser,
89
89
  concurrency,
90
90
  getStats,
91
91
  iterations,
@@ -98,7 +98,7 @@ const benchmark = async ({
98
98
  return async () => {
99
99
  const stopwatch = timer.start()
100
100
 
101
- const browserless = await strategy.onCreate(browserlessFactory, n)
101
+ const browserless = await strategy.onCreate(browser, n)
102
102
  await browserless[method](url, opts)
103
103
  await strategy.onDestroy(browserless, n)
104
104
  const time = stopwatch.end()
@@ -131,12 +131,12 @@ const main = async () => {
131
131
 
132
132
  const strategy = getStrategy({ puppeteer, ...opts })[cli.flags.strategy]()
133
133
  const getStats = processStats()
134
- const browserlessFactory = strategy.onInit()
134
+ const browser = strategy.onInit()
135
135
 
136
136
  console.log()
137
137
  const { times, histogram } = await benchmark({
138
138
  strategy,
139
- browserlessFactory,
139
+ browser,
140
140
  concurrency,
141
141
  getStats,
142
142
  iterations,
@@ -151,7 +151,7 @@ const main = async () => {
151
151
  format: time => prettyMs(time, { keepDecimalsOnWholeSeconds: true })
152
152
  })
153
153
 
154
- await strategy.onClose(browserlessFactory)
154
+ await strategy.onClose(browser)
155
155
  const { uptime, memUsed } = getStats()
156
156
  getStats.destroy()
157
157
 
package/src/timing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const browserlessFactory = require('browserless')
3
+ const createBrowser = require('browserless')
4
4
  const debug = require('debug-logfmt')('browserless:benchmark')
5
5
  const percentile = require('percentile')
6
6
  const timeSpan = require('time-span')
@@ -10,7 +10,7 @@ const HEADLESS = true
10
10
  // const TMP_FOLDER = '/tmp'
11
11
 
12
12
  const createBrowserless = id =>
13
- browserlessFactory({
13
+ createBrowser({
14
14
  headless: HEADLESS,
15
15
  lossyDeviceName: true,
16
16
  timeout: 15000