Socket
Socket
Sign inDemoInstall

autocannon

Package Overview
Dependencies
Maintainers
3
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autocannon - npm Package Compare versions

Comparing version 7.10.0 to 7.11.0

test/aggregateResult.test.js

15

autocannon.js

@@ -21,2 +21,4 @@ #! /usr/bin/env node

const { parseHAR } = require('./lib/parseHAR')
const _aggregateResult = require('./lib/aggregateResult')
const validateOpts = require('./lib/validate')

@@ -34,2 +36,15 @@ if (typeof URL !== 'function') {

module.exports.parseArguments = parseArguments
module.exports.aggregateResult = function aggregateResult (results, opts = {}) {
if (!Array.isArray(results)) {
throw new Error('"results" must be an array of results')
}
opts = validateOpts(opts, false)
if (opts instanceof Error) {
throw opts
}
return _aggregateResult(results, opts)
}
const alias = {

@@ -36,0 +51,0 @@ connections: 'c',

3

lib/aggregateResult.js
'use strict'
const { decodeHist, histAsObj, addPercentiles } = require('./histUtil')
const { decodeHist, getHistograms, histAsObj, addPercentiles } = require('./histUtil')
function aggregateResult (results, opts, histograms) {
results = Array.isArray(results) ? results : [results]
histograms = getHistograms(histograms)

@@ -8,0 +9,0 @@ const aggregated = results.map(r => ({

@@ -140,3 +140,3 @@ 'use strict'

const resultObj = isMainThread ? aggregateResult(result, opts, histograms) : result
const resultObj = isMainThread && !opts.skipAggregateResult ? aggregateResult(result, opts, histograms) : result

@@ -143,0 +143,0 @@ if (opts.forever) {

{
"name": "autocannon",
"version": "7.10.0",
"version": "7.11.0",
"description": "Fast HTTP benchmarking tool written in Node.js",

@@ -41,7 +41,7 @@ "main": "autocannon.js",

"devDependencies": {
"bl": "^5.0.0",
"bl": "^6.0.0",
"busboy": "^0.3.1",
"pre-commit": "^1.1.2",
"proxyquire": "^2.1.3",
"sinon": "^14.0.0",
"sinon": "^15.0.0",
"split2": "^4.0.0",

@@ -48,0 +48,0 @@ "standard": "^17.0.0",

@@ -51,2 +51,4 @@ ![banner](autocannon-banner.png)

The number of requests to make before exiting the benchmark. If set, duration is ignored.
-L NUM
The number of milliseconds to elapse between taking samples. This controls the sample interval, & therefore the total number of samples, which affects statistical analyses. default: 1.
-S/--socketPath

@@ -242,2 +244,8 @@ A path to a Unix Domain Socket or a Windows Named Pipe. A URL is still required to send the correct Host header and path.

In workers mode, `autocannon` uses instances of Node's [Worker](https://nodejs.org/dist/latest/docs/api/worker_threads.html#new-workerfilename-options) class to execute the load tests in multiple threads.
The `amount` and `connections` parameters are divided amongst the workers. If either parameter is not integer divisible by the number of `workers`, the per-worker value is rounded to the lowest integer, or set to `1`, whichever is the higher. All other parameters are applied per-worker as if the test were single-threaded.
**NOTE:** Unlike `amount` and `connections`, the "overall" parameters, `maxOverallRequests` and `overallRate`, are applied **_per worker_**. For example, if you set `connections` to `4`, `workers` to `2` and `maxOverallRequests` to `10`, each worker will receive `2` connections and a `maxOverallRequests` of `10`, resulting in `20` requests being sent.
```js

@@ -295,2 +303,3 @@ 'use strict'

* `amount`: A `Number` stating the number of requests to make before ending the test. This overrides duration and takes precedence, so the test won't end until the number of requests needed to be completed is completed. _OPTIONAL_.
* `sampleInt`: The number of milliseconds to elapse between taking samples. This controls the sample interval, & therefore the total number of samples, which affects statistical analyses. default: 1.
* `timeout`: The number of seconds to wait for a response before. _OPTIONAL_ default: `10`.

@@ -327,2 +336,3 @@ * `pipelining`: The number of [pipelined requests](https://en.wikipedia.org/wiki/HTTP_pipelining) for each connection. Will cause the `Client` API to throw when greater than 1. _OPTIONAL_ default: `1`.

* `tlsOptions`: An `Object` that is passed into `tls.connect` call ([Full list of options](https://nodejs.org/api/tls.html#tls_tls_connect_port_host_options_callback)). Note: this only applies if your URL is secure.
* `skipAggregateResult`: A `Boolean` which allows you to disable the aggregate result phase of an instance run. See [autocannon.aggregateResult](<#autocannon.aggregateResult(results[, opts])>)
* `cb`: The callback which is called on completion of a benchmark. Takes the following params. _OPTIONAL_.

@@ -395,2 +405,18 @@ * `err`: If there was an error encountered with the run.

### autocannon.aggregateResult(results[, opts])
Aggregate the results of one or more autocannon instance runs, where the instances of autocannon have been run with the `skipAggregateResult` option.
This is an advanced use case, where you might be running a load test using autocannon across multiple machines and therefore need to defer aggregating the results to a later time.
* `results`: An array of autocannon instance results, where the instances have been run with the `skipAggregateResult` option set to true. _REQUIRED_.
* `opts`: This is a subset of the options you would pass to the main autocannon API, so you could use the same options object as the one used to run the instances. See [autocannon](<#autocannon(opts[, cb])>) for full descriptions of the options. _REQUIRED_.
* `url`: _REQUIRED_
* `title`: _OPTIONAL_ default: `undefined`
* `socketPath`: _OPTIONAL_
* `connections`: _OPTIONAL_ default: `10`.
* `sampleInt`: _OPTIONAL_ default: `1`
* `pipelining`: _OPTIONAL_ default: `1`
* `workers`: _OPTIONAL_ default: `undefined`
### Autocannon events

@@ -507,3 +533,3 @@

Autocannon can saturate the CPU, e.g. the autocannon process reaches 100%: in those cases,
we recommend using `wrk`.
we recommend using `wrk2`.

@@ -510,0 +536,0 @@ As an example, let's consider a run with 1000 connections on a server

@@ -10,2 +10,4 @@ 'use strict'

let connection = 0
function handle (req, res) {

@@ -25,4 +27,2 @@ res.end('hello world')

let connection = 0
function setupClient (client) {

@@ -29,0 +29,0 @@ client.setBody('connection number', connection++)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc