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

Add p99.9 and p99.99 to request stats distribution csv #1125

Merged
merged 7 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ For full details of the Locust changelog, please see https://github.com/locustio
==========

* Added `--skip-log-setup` to disable Locust's default logging setup.
* Allow custom clients to set request response time to None. Those requests will be excluded
* Added `--stop-timeout` to allow tasks to finish running their iteration before stopping
* Added 99.9 and 99.99 percentile response times to csv output
* Allow custom clients to set request response time to None. Those requests will be excluded
when calculating median, average, min, max and percentile response times.
* Renamed the last row in statistics table from "Total" to "Aggregated" (since the values aren't
a sum of the individual table rows).
Expand Down
8 changes: 4 additions & 4 deletions docs/retrieving-stats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ This data will write two files with ``_distribution.csv`` and ``_requests.csv``
.. code-block:: console

$ cat example_distribution.csv
"Name","# requests","50%","66%","75%","80%","90%","95%","98%","99%","100%"
"GET /",31,4,4,4,4,4,4,4,4,4
"Name","# requests","50%","66%","75%","80%","90%","95%","98%","99%","99.9%","99.99%","100%"
"GET /",31,4,4,4,4,4,4,4,4,4,4,4
"/does_not_exist",0,"N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A"
"GET /stats/requests",38,3,4,4,4,4,5,5,5,5
"None Total",69,3,4,4,4,4,4,5,5,5
"GET /stats/requests",38,3,4,4,4,4,5,5,5,5,5,5
"None Total",69,3,4,4,4,4,4,5,5,5,5,5

and:

Expand Down
2 changes: 1 addition & 1 deletion docs/writing-a-locustfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ Response's *content* attribute will be set to None, and its *status_code* will b
Manually controlling if a request should be considered successful or a failure
------------------------------------------------------------------------------

By default, requests are marked as failed requests unless the HTTP response code is OK (2xx).
By default, requests are marked as failed requests unless the HTTP response code is OK (<400).
Most of the time, this default is what you want. Sometimes however—for example when testing
a URL endpoint that you expect to return 404, or testing a badly designed system that might
return *200 OK* even though an error occurred—there's a need for manually controlling if
Expand Down
10 changes: 7 additions & 3 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def get_current_response_time_percentile(self, percent):
percent,
)

def percentile(self, tpl=" %-" + str(STATS_NAME_WIDTH) + "s %8d %6d %6d %6d %6d %6d %6d %6d %6d %6d"):
def percentile(self, tpl=" %-" + str(STATS_NAME_WIDTH) + "s %8d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d"):
if not self.num_requests:
raise ValueError("Can't calculate percentile on url with no successful requests")

Expand All @@ -489,6 +489,8 @@ def percentile(self, tpl=" %-" + str(STATS_NAME_WIDTH) + "s %8d %6d %6d %6d %6d
self.get_response_time_percentile(0.95),
self.get_response_time_percentile(0.98),
self.get_response_time_percentile(0.99),
self.get_response_time_percentile(0.999),
self.get_response_time_percentile(0.9999),
self.get_response_time_percentile(1.00)
)

Expand Down Expand Up @@ -753,13 +755,15 @@ def distribution_csv():
'"95%"',
'"98%"',
'"99%"',
'"99.9%"',
'"99.99%"',
'"100%"',
))]
for s in chain(sort_stats(runners.locust_runner.request_stats), [runners.locust_runner.stats.total]):
if s.num_requests:
rows.append(s.percentile(tpl='"%s",%i,%i,%i,%i,%i,%i,%i,%i,%i,%i'))
rows.append(s.percentile(tpl='"%s",%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i,%i'))
else:
rows.append('"%s",0,"N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A"' % s.name)
rows.append('"%s",0,"N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A"' % s.name)

return "\n".join(rows)

Expand Down
4 changes: 2 additions & 2 deletions locust/test/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ def test_percentile_rounded_down(self):
s1 = StatsEntry(self.stats, "rounding down!", "GET")
s1.log(122, 0) # (rounded 120) min
actual_percentile = s1.percentile()
self.assertEqual(actual_percentile, " GET rounding down! 1 120 120 120 120 120 120 120 120 120")
self.assertEqual(actual_percentile, " GET rounding down! 1 120 120 120 120 120 120 120 120 120 120 120")

def test_percentile_rounded_up(self):
s2 = StatsEntry(self.stats, "rounding up!", "GET")
s2.log(127, 0) # (rounded 130) min
actual_percentile = s2.percentile()
self.assertEqual(actual_percentile, " GET rounding up! 1 130 130 130 130 130 130 130 130 130")
self.assertEqual(actual_percentile, " GET rounding up! 1 130 130 130 130 130 130 130 130 130 130 130")

def test_error_grouping(self):
# reset stats
Expand Down