Skip to content

Commit

Permalink
Merge pull request #2806 from andrewbaldwin44/feature/avg-response-time
Browse files Browse the repository at this point in the history
Replace total avg response time with 50 percentile (avg was broken)
  • Loading branch information
cyberw authored Jul 18, 2024
2 parents 213f50f + 1618d1e commit c4b6571
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 263 deletions.
3 changes: 1 addition & 2 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def resize_handler(signum: int, frame: FrameType | None):
PERCENTILES_TO_REPORT = [0.50, 0.66, 0.75, 0.80, 0.90, 0.95, 0.98, 0.99, 0.999, 0.9999, 1.0]

PERCENTILES_TO_STATISTICS = [0.95, 0.99]
PERCENTILES_TO_CHART = [0.95]
PERCENTILES_TO_CHART = [0.5, 0.95]


class RequestStatsAdditionError(Exception):
Expand Down Expand Up @@ -675,7 +675,6 @@ def to_dict(self, escape_string_values=False):
"safe_name": escape(self.name, quote=False),
"num_requests": self.num_requests,
"num_failures": self.num_failures,
"avg_response_time": self.avg_response_time,
"min_response_time": 0 if self.min_response_time is None else proper_round(self.min_response_time),
"max_response_time": proper_round(self.max_response_time),
"current_rps": self.current_rps,
Expand Down
2 changes: 0 additions & 2 deletions locust/test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,9 @@ def test_stats(self):
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("Aggregated", data["stats"][1]["name"])
self.assertEqual(1, data["stats"][1]["num_requests"])
self.assertEqual(120, data["stats"][1]["avg_response_time"])

def test_stats_cache(self):
self.stats.log_request("GET", "/test", 120, 5612)
Expand Down
1 change: 0 additions & 1 deletion locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ def request_stats() -> Response:
if stats:
report["total_rps"] = total_stats["current_rps"]
report["total_fail_per_sec"] = total_stats["current_fail_per_sec"]
report["total_avg_response_time"] = total_stats["avg_response_time"]
report["fail_ratio"] = environment.runner.stats.total.fail_ratio
report["current_response_time_percentiles"] = {
f"response_time_percentile_{percentile}": environment.runner.stats.total.get_current_response_time_percentile(
Expand Down
Loading

0 comments on commit c4b6571

Please sign in to comment.