From 57082cc42874eedc55b6c06e678c22fd1efb7ef4 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Thu, 17 Mar 2022 14:18:06 -0300 Subject: [PATCH 1/3] update: use sample interval default 1000 --- autocannon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autocannon.js b/autocannon.js index 2a11ba6b..0bc68136 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, From 152951691315654b4a213c4b998644aa3c065e8a Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Thu, 17 Mar 2022 14:21:31 -0300 Subject: [PATCH 2/3] docs(-L): fix seconds -> milliseconds --- help.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From cb3a4976eacb520c73abf15fc95f7a3f65c5d689 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Sat, 19 Mar 2022 12:10:34 -0300 Subject: [PATCH 3/3] fix(sampleInt): remove parse from seconds to milliseconds --- autocannon.js | 2 -- lib/defaultOptions.js | 2 +- test/sampleInt.test.js | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/autocannon.js b/autocannon.js index 0bc68136..03647997 100755 --- a/autocannon.js +++ b/autocannon.js @@ -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/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) {