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

Format of reports when they’re piped into a file: Control characters & JSON #474

Closed
leafac opened this issue Nov 25, 2022 · 5 comments
Closed
Assignees

Comments

@leafac
Copy link

leafac commented Nov 25, 2022

First of all, thanks for autocannon. I’m starting to use it and liking it 😁

I’ve noticed two formatting issues when piping the output of autocannon into a file.

Issue 1

autocannon prints the control characters that would have made a terminal use different colors. For example:

$ npx autocannon --json http://127.0.0.1:4000/ > output.txt 2>&1

output.txt

[...]

�[90m┌─────────�[39m�[90m┬──────�[39m�[90m┬──────�[39m�[90m┬───────�[39m�[90m┬──────�[39m�[90m┬─────────�[39m�[90m┬─────────�[39m�[90m┬──────┐�[39m
�[90m│�[39m�[31m Stat    �[39m�[90m│�[39m�[31m 2.5% �[39m�[90m│�[39m�[31m 50%  �[39m�[90m│�[39m�[31m 97.5% �[39m�[90m│�[39m�[31m 99%  �[39m�[90m│�[39m�[31m Avg     �[39m�[90m│�[39m�[31m Stdev   �[39m�[90m│�[39m�[31m Max  �[39m�[90m│�[39m
�[90m├─────────�[39m�[90m┼──────�[39m�[90m┼──────�[39m�[90m┼───────�[39m�[90m┼──────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼──────┤�[39m
�[90m│�[39m Latency �[90m│�[39m 0 ms �[90m│�[39m 0 ms �[90m│�[39m 1 ms  �[90m│�[39m 1 ms �[90m│�[39m 0.05 ms �[90m│�[39m 0.23 ms �[90m│�[39m 5 ms �[90m│�[39m
�[90m└─────────�[39m�[90m┴──────�[39m�[90m┴──────�[39m�[90m┴───────�[39m�[90m┴──────�[39m�[90m┴─────────�[39m�[90m┴─────────�[39m�[90m┴──────┘�[39m
�[90m┌───────────�[39m�[90m┬─────────�[39m�[90m┬─────────�[39m�[90m┬─────────�[39m�[90m┬─────────�[39m�[90m┬─────────�[39m�[90m┬─────────�[39m�[90m┬─────────┐�[39m
�[90m│�[39m�[31m Stat      �[39m�[90m│�[39m�[31m 1%      �[39m�[90m│�[39m�[31m 2.5%    �[39m�[90m│�[39m�[31m 50%     �[39m�[90m│�[39m�[31m 97.5%   �[39m�[90m│�[39m�[31m Avg     �[39m�[90m│�[39m�[31m Stdev   �[39m�[90m│�[39m�[31m Min     �[39m�[90m│�[39m
�[90m├───────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────┤�[39m
�[90m│�[39m Req/Sec   �[90m│�[39m 16639   �[90m│�[39m 16639   �[90m│�[39m 19039   �[90m│�[39m 20127   �[90m│�[39m 18891.2 �[90m│�[39m 1090.66 �[90m│�[39m 16629   �[90m│�[39m
�[90m├───────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────�[39m�[90m┼─────────┤�[39m
�[90m│�[39m Bytes/Sec �[90m│�[39m 3.96 MB �[90m│�[39m 3.96 MB �[90m│�[39m 4.53 MB �[90m│�[39m 4.79 MB �[90m│�[39m 4.5 MB  �[90m│�[39m 260 kB  �[90m│�[39m 3.96 MB �[90m│�[39m
�[90m└───────────�[39m�[90m┴─────────�[39m�[90m┴─────────�[39m�[90m┴─────────�[39m�[90m┴─────────�[39m�[90m┴─────────�[39m�[90m┴─────────�[39m�[90m┴─────────┘�[39m

[...]

I suppose that autocannon could detect that it isn’t printing to the terminal and omit the control characters.

Issue 2

The documentation says that the --json option “will cause the progress bar and results not to be rendered.” But that doesn’t seem to be the case for me—I’m getting the results and some JSON at the end. For example:

$ npx autocannon --json http://127.0.0.1:4000/ > output.txt 2>&1

output.txt

Running 10s test @ http://127.0.0.1:4000/
10 connections

[THAT BIG TABLE FULL OF CONTROL CHARACTERS FROM ABOVE]

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

217k requests in 11.01s, 51.8 MB read
{"url":"http://127.0.0.1:4000/","connections":10,"sampleInt":1000,"pipelining":1,"workers":0,"duration":11.01,"samples":11,"start":"2022-11-25T15:13:44.244Z","finish":"2022-11-25T15:13:55.251Z","errors":0,"timeouts":0,"mismatches":0,"non2xx":0,"resets":0,"1xx":0,"2xx":217457,"3xx":0,"4xx":0,"5xx":0,"statusCodeStats":{"200":{"count":217457}},"latency":{"average":0.04,"mean":0.04,"stddev":0.19,"min":1,"max":5,"p0_001":0,"p0_01":0,"p0_1":0,"p1":0,"p2_5":0,"p10":0,"p25":0,"p50":0,"p75":0,"p90":0,"p97_5":1,"p99":1,"p99_9":2,"p99_99":3,"p99_999":4,"totalCount":217457},"requests":{"average":19769.46,"mean":19769.46,"stddev":900.16,"min":17550,"max":20283,"total":217457,"p0_001":17551,"p0_01":17551,"p0_1":17551,"p1":17551,"p2_5":17551,"p10":18239,"p25":20111,"p50":20207,"p75":20223,"p90":20223,"p97_5":20287,"p99":20287,"p99_9":20287,"p99_99":20287,"p99_999":20287,"sent":217467},"throughput":{"average":4705093.82,"mean":4705093.82,"stddev":213767.91,"min":4176900,"max":4827354,"total":51754766,"p0_001":4177919,"p0_01":4177919,"p0_1":4177919,"p1":4177919,"p2_5":4177919,"p10":4341759,"p25":4784127,"p50":4808703,"p75":4812799,"p90":4812799,"p97_5":4829183,"p99":4829183,"p99_9":4829183,"p99_99":4829183,"p99_999":4829183}}
@mcollina
Copy link
Owner

Sorry for the wait! I've been quite slow in catching up with my GH notifications.

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@shrthk-7
Copy link

shrthk-7 commented Jun 9, 2023

I'd like to assign myself this issue if that's okay

@mcollina
Copy link
Owner

go for it!

@proddy
Copy link

proddy commented Dec 29, 2023

did this change go in?

@10xLaCroixDrinker
Copy link
Contributor

This should be closed now

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

No branches or pull requests

5 participants