Skip to content

Commit

Permalink
fix(stats): return None when current response time not in percentile …
Browse files Browse the repository at this point in the history
…window

This prevents the data from being displayed on the UI chart during the
response time calculation's indeterminate state.

Issue: locustio#1852
  • Loading branch information
obradovichv committed Aug 18, 2021
1 parent 3efefdf commit 9137f57
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def get_current_response_time_percentile(self, percent):
percent,
)
# if time was not in response times cache window
return 0
return None

def percentile(self):
if not self.num_requests:
Expand Down
2 changes: 1 addition & 1 deletion locust/test/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def test_get_current_response_time_percentile_outside_cache_window(self):
s = StatsEntry(self.stats, "/", "GET", use_response_times_cache=True)
# an empty response times cache, current time will not be in this cache
s.response_times_cache = {}
self.assertEqual(0, s.get_current_response_time_percentile(0.95))
self.assertEqual(None, s.get_current_response_time_percentile(0.95))

def test_diff_response_times_dicts(self):
self.assertEqual(
Expand Down

0 comments on commit 9137f57

Please sign in to comment.