Skip to content

Commit

Permalink
Rename the label of the last “Total” row to “Aggregated” since it isn…
Browse files Browse the repository at this point in the history
…’t actually a sum of the individual rows. Fixes #629.
  • Loading branch information
heyman committed Oct 24, 2019
1 parent abd8052 commit a664d7a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Changelog Highlights
####################

Unreleased
==========

* Renamed the last row in statistics from "Total" to "Aggregated" (since the values aren't a sum of the
individual table rows).


For full details of the Locust changelog, please see https://github.com/locustio/locust/blob/master/CHANGELOG.md

0.12.1
Expand Down
1 change: 1 addition & 0 deletions locust/static/locust.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ var report;

function renderTable(report) {
var totalRow = report.stats.pop();
totalRow.is_aggregated = true;
var sortedStats = (report.stats).sort(sortBy(sortAttribute, desc));
sortedStats.push(totalRow);
$('#stats tbody').empty();
Expand Down
6 changes: 3 additions & 3 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class RequestStats(object):
def __init__(self):
self.entries = {}
self.errors = {}
self.total = StatsEntry(self, "Total", None, use_response_times_cache=True)
self.total = StatsEntry(self, "Aggregated", None, use_response_times_cache=True)
self.start_time = None

@property
Expand Down Expand Up @@ -129,7 +129,7 @@ def clear_all(self):
"""
Remove all stats entries and errors
"""
self.total = StatsEntry(self, "Total", None, use_response_times_cache=True)
self.total = StatsEntry(self, "Aggregated", None, use_response_times_cache=True)
self.entries = {}
self.errors = {}
self.start_time = None
Expand Down Expand Up @@ -633,7 +633,7 @@ def print_stats(stats):
except ZeroDivisionError:
fail_percent = 0

console_logger.info((" %-" + str(STATS_NAME_WIDTH) + "s %7d %12s %42.2f") % ('Total', total_reqs, "%d(%.2f%%)" % (total_failures, fail_percent), total_rps))
console_logger.info((" %-" + str(STATS_NAME_WIDTH) + "s %7d %12s %42.2f") % ('Aggregated', total_reqs, "%d(%.2f%%)" % (total_failures, fail_percent), total_rps))
console_logger.info("")

def print_percentile_stats(stats):
Expand Down
2 changes: 1 addition & 1 deletion locust/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ <h2>Version <a href="https://github.com/locustio/locust/releases/tag/{{version}}
<script type="text/javascript" src="./static/vintage.js"></script>
<script type="text/x-jqote-template" id="stats-template">
<![CDATA[
<tr class="<%=(alternate ? "dark" : "")%> <%=(this.name == "Total" ? "total" : "")%>">
<tr class="<%=(alternate ? "dark" : "")%> <%=(this.is_aggregated ? "total" : "")%>">
<td><%= (this.method ? this.method : "") %></td>
<td class="name" title="<%= this.name %>"><%= this.safe_name %></td>
<td class="numeric"><%= this.num_requests %></td>
Expand Down
8 changes: 4 additions & 4 deletions locust/test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def test_stats(self):
self.assertEqual(200, response.status_code)

data = json.loads(response.text)
self.assertEqual(2, len(data["stats"])) # one entry plus Total
self.assertEqual(2, len(data["stats"])) # one entry plus Aggregated
self.assertEqual("/<html>", data["stats"][0]["name"])
self.assertEqual("/&lt;html&gt;", data["stats"][0]["safe_name"])
self.assertEqual("GET", data["stats"][0]["method"])
self.assertEqual(120, data["stats"][0]["avg_response_time"])

self.assertEqual("Total", data["stats"][1]["name"])
self.assertEqual("Aggregated", data["stats"][1]["name"])
self.assertEqual(1, data["stats"][1]["num_requests"])
self.assertEqual(120, data["stats"][1]["avg_response_time"])

Expand All @@ -63,7 +63,7 @@ def test_stats_cache(self):
response = requests.get("http://127.0.0.1:%i/stats/requests" % self.web_port)
self.assertEqual(200, response.status_code)
data = json.loads(response.text)
self.assertEqual(2, len(data["stats"])) # one entry plus Total
self.assertEqual(2, len(data["stats"])) # one entry plus Aggregated

# add another entry
stats.global_stats.log_request("GET", "/test2", 120, 5612)
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_distribution_stats_csv(self):
self.assertEqual('"GET /test2"', row[0])
# check total row
total_cols = rows[len(rows)-1].split(",")
self.assertEqual('"Total"', total_cols[0])
self.assertEqual('"Aggregated"', total_cols[0])
# verify that the 95%, 98%, 99% and 100% percentiles are 1200
for value in total_cols[-4:]:
self.assertEqual('1200', value)
Expand Down

0 comments on commit a664d7a

Please sign in to comment.