Skip to content

Commit

Permalink
Updated api & release notes for ips functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberw committed Jan 24, 2020
1 parent 9377a7e commit 4a2da70
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Built in wait_time functions
============================

.. automodule:: locust.wait_time
:members: between, constant, constant_pacing
:members: between, constant, constant_pacing, constant_ips, constant_ips_total

HttpSession class
=================
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In development (master)

* Continuously measure CPU usage and emit a warning if we get a five second average above 90%
* Show CPU usage of slave nodes in the Web UI

* Add new timers that target iterations per second: constant_ips (the inverse of constant_pacing) and constant_ips_total (total iterations per second, across locusts)

0.13.5
======
Expand Down
4 changes: 3 additions & 1 deletion locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, locust_classes, options):
self.state = STATE_INIT
self.hatching_greenlet = None
self.stepload_greenlet = None
self.target_user_count = None
self.current_cpu_usage = 0
self.cpu_warning_emitted = False
self.ips_warning_emitted = False
Expand Down Expand Up @@ -216,6 +217,7 @@ def start_hatching(self, locust_count, hatch_rate, wait=False):
self.exceptions = {}
self.cpu_warning_emitted = False
self.slave_cpu_warning_emitted = False
self.target_user_count = locust_count
events.locust_start_hatching.fire()

# Dynamically changing the locust count
Expand Down Expand Up @@ -298,6 +300,7 @@ def on_locust_error(locust_instance, exception, tb):
events.locust_error += on_locust_error

def start_hatching(self, locust_count, hatch_rate, wait=False):
self.target_user_count = locust_count
if hatch_rate > 100:
logger.warning("Your selected hatch rate is very high (>100), and this is known to sometimes cause issues. Do you really need to ramp up that fast?")
if self.hatching_greenlet:
Expand Down Expand Up @@ -329,7 +332,6 @@ class MasterLocustRunner(DistributedLocustRunner):
def __init__(self, *args, **kwargs):
super(MasterLocustRunner, self).__init__(*args, **kwargs)
self.slave_cpu_warning_emitted = False
self.target_user_count = None

class SlaveNodesDict(dict):
def get_by_state(self, state):
Expand Down
4 changes: 2 additions & 2 deletions locust/wait_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ def wait_time_func(self):
)
return 1.0 / ips
current_time = float(time())
unstarted_clients = lr.num_clients - len(lr.locusts)
unstarted_clients = lr.target_user_count - lr.user_count
if not hasattr(self, "_cp_last_run"):
self._cp_last_run = 0
self._cp_target_missed = False
next_time = self._cp_last_run + (lr.num_clients + unstarted_clients) / float(ips)
next_time = self._cp_last_run + (lr.target_user_count + unstarted_clients) / float(ips)
if current_time > next_time:
if lr.state == runners.STATE_RUNNING and self._cp_target_missed and not lr.ips_warning_emitted:
logging.warning("Failed to reach target ips, even after rampup has finished")
Expand Down

0 comments on commit 4a2da70

Please sign in to comment.