Skip to content

Instantly share code, notes, and snippets.

@jphalip
Last active April 5, 2019 11:34
Show Gist options
  • Save jphalip/c13c1c5fba7f9a6a16ce to your computer and use it in GitHub Desktop.
Save jphalip/c13c1c5fba7f9a6a16ce to your computer and use it in GitHub Desktop.
Locust debugging
from locust import HttpLocust, TaskSet, task
from locust import events
class UserBehavior(TaskSet):
@task
def google(self):
self.client.get("/")
class WebsiteUser(HttpLocust):
host = 'https://www.google.com'
task_set = UserBehavior
min_wait = 5000
max_wait = 5000
def track_success(**kwargs):
print kwargs
events.request_success += track_success
$ locust --no-web -c 2 -r 2 -n 6 --only-summary
/home/vagrant/.virtualenvs/myenv/local/lib/python2.7/site-packages/locust/rpc/__init__.py:6: UserWarning: WARNING: Using pure Python socket RPC implementation instead of zmq. If running in distributed mode, this could cause a performance decrease. We recommend you to install the pyzmq python package when running in distributed mode.
warnings.warn("WARNING: Using pure Python socket RPC implementation instead of zmq. If running in distributed mode, this could cause a performance decrease. We recommend you to install the pyzmq python package when running in distributed mode.")
[2014-10-08 17:29:04,536] precise64/INFO/locust.main: Starting Locust 0.7.2
[2014-10-08 17:29:04,537] precise64/INFO/locust.runners: Hatching and swarming 2 clients at the rate 2 clients/s...
[2014-10-08 17:29:04,677] precise64/INFO/stdout: {'request_type': 'GET', 'response_length': 17779, 'name': '/', 'response_time': 139}
[2014-10-08 17:29:04,677] precise64/INFO/stdout:
[2014-10-08 17:29:05,152] precise64/INFO/stdout: {'request_type': 'GET', 'response_length': 17770, 'name': '/', 'response_time': 113}
[2014-10-08 17:29:05,152] precise64/INFO/stdout:
[2014-10-08 17:29:05,541] precise64/INFO/locust.runners: All locusts hatched: WebsiteUser: 2
[2014-10-08 17:29:05,542] precise64/INFO/locust.runners: Resetting stats
[2014-10-08 17:29:09,747] precise64/INFO/stdout: {'request_type': 'GET', 'response_length': 17808, 'name': '/', 'response_time': 69}
[2014-10-08 17:29:09,748] precise64/INFO/stdout:
[2014-10-08 17:29:10,218] precise64/INFO/stdout: {'request_type': 'GET', 'response_length': 17794, 'name': '/', 'response_time': 65}
[2014-10-08 17:29:10,219] precise64/INFO/stdout:
[2014-10-08 17:29:14,925] precise64/INFO/stdout: {'request_type': 'GET', 'response_length': 17803, 'name': '/', 'response_time': 59}
[2014-10-08 17:29:14,925] precise64/INFO/stdout:
[2014-10-08 17:29:15,293] precise64/INFO/stdout: {'request_type': 'GET', 'response_length': 17794, 'name': '/', 'response_time': 65}
[2014-10-08 17:29:15,303] precise64/INFO/stdout:
[2014-10-08 17:29:19,999] precise64/INFO/stdout: {'request_type': 'GET', 'response_length': 17803, 'name': '/', 'response_time': 72}
[2014-10-08 17:29:19,999] precise64/INFO/stdout:
[2014-10-08 17:29:20,365] precise64/INFO/stdout: {'request_type': 'GET', 'response_length': 17803, 'name': '/', 'response_time': 58}
[2014-10-08 17:29:20,365] precise64/INFO/stdout:
[2014-10-08 17:29:25,434] precise64/INFO/locust.runners: All locusts dead
[2014-10-08 17:29:25,434] precise64/INFO/locust.main: Shutting down (exit code 0), bye.
Name # reqs # fails Avg Min Max | Median req/s
--------------------------------------------------------------------------------------------------------------------------------------------
GET / 6 0(0.00%) 64 58 72 | 65 0.40
--------------------------------------------------------------------------------------------------------------------------------------------
Total 6 0(0.00%) 0.40
Percentage of the requests completed within given times
Name # reqs 50% 66% 75% 80% 90% 95% 98% 99% 100%
--------------------------------------------------------------------------------------------------------------------------------------------
GET / 6 65 65 69 69 72 72 72 72 72
--------------------------------------------------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment