Skip to content

Commit

Permalink
update: use sample interval default 1000 (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS authored Mar 19, 2022
1 parent 9953dc6 commit 367d5a0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 1 addition & 3 deletions autocannon.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const defaults = {
timeout: 10,
pipelining: 1,
duration: 10,
sampleInt: 1,
sampleInt: 1000,
reconnectRate: 0,
renderLatencyTable: false,
renderProgressBar: true,
Expand All @@ -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['--']
}
Expand Down
4 changes: 2 additions & 2 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/defaultOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const defaultOptions = {
method: 'GET',
duration: 10,
connections: 10,
sampleInt: 1,
sampleInt: 1000,
pipelining: 1,
timeout: 10,
maxConnectionRequests: 0,
Expand Down
6 changes: 3 additions & 3 deletions test/sampleInt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]

Expand All @@ -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) {
Expand Down

0 comments on commit 367d5a0

Please sign in to comment.