Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: printing of result when interrupted #438

Merged
merged 1 commit into from
Mar 29, 2022
Merged

fix: printing of result when interrupted #438

merged 1 commit into from
Mar 29, 2022

Conversation

cdscih
Copy link
Contributor

@cdscih cdscih commented Mar 26, 2022

Hello,

I just noticed that whenever I forcefully (CTRL-C) interrupt the execution of this script

'use strict'

const autocannon = require('autocannon')

const instance = autocannon({
  url: 'http://localhost:3000'
})

// this is used to kill the instance on CTRL-C
process.once('SIGINT', () => {
  instance.stop()
})

// just render results
autocannon.track(instance, {renderProgressBar: false})

the log in the console is a little broken because the first row isn't being written on a new line.

Example:

^C┌─────────┬──────┬──────┬───────┬──────┬────────┬─────────┬────────┐
│ Stat    │ 2.5% │ 50%  │ 97.5% │ 99%  │ Avg    │ Stdev   │ Max    │
├─────────┼──────┼──────┼───────┼──────┼────────┼─────────┼────────┤
│ Latency │ 1 ms │ 2 ms │ 5 ms  │ 7 ms │ 2.2 ms │ 5.52 ms │ 230 ms │
└─────────┴──────┴──────┴───────┴──────┴────────┴─────────┴────────┘
┌───────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐
│ Stat      │ 1%     │ 2.5%   │ 50%    │ 97.5%  │ Avg    │ Stdev  │ Min    │
├───────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
│ Req/Sec   │ 2657   │ 2657   │ 3905   │ 4055   │ 3660.5 │ 582.09 │ 2657   │
├───────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
│ Bytes/Sec │ 497 kB │ 497 kB │ 730 kB │ 758 kB │ 684 kB │ 109 kB │ 497 kB │
└───────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┘

Req/Bytes counts sampled once per second.
# of samples: 4

15k requests in 4.03s, 2.74 MB read

I thought this fix could make sense for all use cases so I decided to just send a pull request to fix it globally.

ps. This is my first pull request ever. Hope I'm not doing anything wrong! 🙈

Copy link
Owner

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@cdscih
Copy link
Contributor Author

cdscih commented Mar 28, 2022

I think i fixed the failing tests btw. Do I need to do something else to close this?

@mcollina
Copy link
Owner

Still lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants