From 367d5a06e40d5dc5286eff123d30fc9296a6fea5 Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Sat, 19 Mar 2022 13:22:25 -0300 Subject: [PATCH] update: use sample interval default 1000 (#436) --- autocannon.js | 4 +--- help.txt | 4 ++-- lib/defaultOptions.js | 2 +- test/sampleInt.test.js | 6 +++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/autocannon.js b/autocannon.js index 2a11ba6b..03647997 100755 --- a/autocannon.js +++ b/autocannon.js @@ -72,7 +72,7 @@ const defaults = { timeout: 10, pipelining: 1, duration: 10, - sampleInt: 1, + sampleInt: 1000, reconnectRate: 0, renderLatencyTable: false, renderProgressBar: true, @@ -98,8 +98,6 @@ function parseArguments (argvs) { argv.url = argv._.length > 1 ? argv._ : argv._[0] - argv.sampleInt = Math.round(argv.sampleInt * 1000) // convert seconds to milliseconds - if (argv.onPort) { argv.spawn = argv['--'] } diff --git a/help.txt b/help.txt index c736971e..af17ca39 100644 --- a/help.txt +++ b/help.txt @@ -13,8 +13,8 @@ Available options: The number of seconds to run the autocannon. default: 10. -a/--amount NUM The number of requests to make before exiting the benchmark. If set, duration is ignored. - -L SEC - The number of seconds to elapse between taking samples. This controls the sample interval, & therefore the total number of samples, which affects statistical analyses. default: 1. + -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 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. -w/--workers diff --git a/lib/defaultOptions.js b/lib/defaultOptions.js index 4d0fb74a..174ef082 100644 --- a/lib/defaultOptions.js +++ b/lib/defaultOptions.js @@ -5,7 +5,7 @@ const defaultOptions = { method: 'GET', duration: 10, connections: 10, - sampleInt: 1, + sampleInt: 1000, pipelining: 1, timeout: 10, maxConnectionRequests: 0, diff --git a/test/sampleInt.test.js b/test/sampleInt.test.js index 8efdde48..4a177744 100644 --- a/test/sampleInt.test.js +++ b/test/sampleInt.test.js @@ -48,11 +48,11 @@ test('validate should not return an error', (t) => { t.equal(result.sampleInt, 2) }) -test('parseArguments should return sampleInt in ms (2000)', (t) => { +test('parseArguments should accept value in ms (2000)', (t) => { t.plan(1) const args = [ - '-L', 2, + '-L', 2000, 'https://github.com/mcollina/autocannon' ] @@ -66,7 +66,7 @@ test('run should return sampleInt == 2000 & samples == 3', (t) => { initJob({ duration: 6, - sampleInt: 2000, // an input of 2 seconds will be passed in as 2000 because this is after it is parsed in autocannon.js + sampleInt: 2000, url: 'https://github.com/mcollina/autocannon' }, (err, res) => { if (err) {