-
Notifications
You must be signed in to change notification settings - Fork 3k
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
optional ramping feature; sorting stats by column #11
Changes from 28 commits
6bdc65a
376f663
d0b6918
9b2d70f
20a1c9b
db10e4d
c17a67f
84b4e9f
2f935c3
8398e0e
e8646a2
fad9e70
84caf26
30d6dda
a20579e
e8e868c
f725cbc
4471213
6b62099
56772b2
8a5b695
2fcb4b4
92ee44d
a970533
72898e3
e3f03b4
eb43c8c
975c78a
4ff4b88
0356756
c54ad5e
db74842
6540207
652ea56
d9a9f66
4a6e039
8efe8a6
5c7cfcf
2ba5b60
9b03484
6b3068a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from stats import percentile, RequestStats | ||
from collections import deque | ||
import events | ||
import math | ||
|
||
master_response_times = deque([]) | ||
slave_response_times = [] | ||
|
||
# The time window in seconds that current_percentile use data from | ||
PERCENTILE_TIME_WINDOW = 15.0 | ||
|
||
def current_percentile(percent): | ||
from core import locust_runner, MasterLocustRunner | ||
if isinstance(locust_runner, MasterLocustRunner): | ||
return percentile(sorted([item for sublist in master_response_times for item in sublist]), percent) | ||
else: | ||
return percentile(sorted(master_response_times), percent) | ||
|
||
def on_request_success(_, response_time, _2): | ||
from core import locust_runner, MasterLocustRunner | ||
if isinstance(locust_runner, MasterLocustRunner): | ||
slave_response_times.append(response_time) | ||
else: | ||
# The locust_runner is not running in distributed mode | ||
master_response_times.append(response_time) | ||
|
||
# remove from the queue | ||
rps = RequestStats.sum_stats().current_rps | ||
if len(master_response_times) > rps*PERCENTILE_TIME_WINDOW: | ||
for i in xrange(len(master_response_times) - int(math.ceil(rps*PERCENTILE_TIME_WINDOW))): | ||
master_response_times.popleft() | ||
|
||
def on_report_to_master(_, data): | ||
data["current_responses"] = slave_response_times | ||
global slave_response_times | ||
slave_response_times = [] | ||
|
||
def on_slave_report(_, data): | ||
from core import locust_runner, SLAVE_REPORT_INTERVAL | ||
|
||
if "current_responses" in data: | ||
master_response_times.append(data["current_responses"]) | ||
|
||
# remove from the queue | ||
slaves = locust_runner.slave_count | ||
response_times_per_slave_count = PERCENTILE_TIME_WINDOW/SLAVE_REPORT_INTERVAL | ||
if len(master_response_times) > slaves * response_times_per_slave_count: | ||
master_response_times.popleft() | ||
|
||
events.request_success += on_request_success | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The setting up of the event listeners should probably be conditioned by an if block, so that the ramping stats overhead isn't activated by mistake if someone imports rampstats. The best thing would probably be to set up the listeners in either main.py or core.py (but still keep the listener functions in rampstats.py of course). |
||
events.report_to_master += on_report_to_master | ||
events.slave_report += on_slave_report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might have forgot to commit autotune.py?