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

Adding individual status code statistics table #347

Merged
merged 4 commits into from Mar 10, 2021
Merged

Adding individual status code statistics table #347

merged 4 commits into from Mar 10, 2021

Conversation

maxfortun
Copy link
Contributor

#346
Add --renderStatusCodes flag to render individual status code statistics table

┌──────┬───────┐
│ Code │ Count │
├──────┼───────┤
│ 401  │ 124   │
└──────┴───────┘

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.

would you mind to add a unit test?

Copy link
Contributor

@simoneb simoneb left a comment

Choose a reason for hiding this comment

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

There's a room for an overall improvement here. Status codes are already being aggregated, but they're aggregated by "index": 2xx, 3xx, ..., which is less granular than what you're trying to achieve with this change. Instead of creating an additional implementation which does the same but in a more granular way, why don't you make the existing implementation more granular and use the finer grained granularity when renderStatusCode is true, and fallback to the existing behavior when it's false?

Comment on lines +223 to +227
if (!statusCodeStats[statusCode]) {
statusCodeStats[statusCode] = { count: 1 }
} else {
statusCodeStats[statusCode].count++
}
Copy link
Contributor

Choose a reason for hiding this comment

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

is there any reason to not use the object values as the count, instead of having an object with a single property count? It would be more consistent with how the other stats are aggregated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@simoneb , you are absolutely right, there are many ways this could be improved. I was not certain of how far I can mod the code and still remain within the original author's intent. My goal was additive change only without impacting any of the existing functionality. If you believe that you can take this further, please do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as object with a single property, I envision that there may be other attributes aggregated about each individual statusCode, other than a count, and thus wanted to provide a harness for that. An example could be request timing average per code.

Copy link
Contributor

Choose a reason for hiding this comment

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

@maxfortun on the overall approach let's hear what @mcollina thinks. On the count property, if it's not necessary, I'd say avoid it

@maxfortun
Copy link
Contributor Author

@mcollina unit test added

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

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

opts = autocannon.parseArguments(args)
}

const resultStr = autocannon.printResult(exampleResult, opts)
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure this change to the tests is actually being used anywhere. Can you please confirm?

Copy link
Contributor Author

@maxfortun maxfortun Mar 9, 2021

Choose a reason for hiding this comment

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

Looks like I forgot to add a file.
Fixed. Thanks.

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

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.

None yet

3 participants