summaryrefslogtreecommitdiff
path: root/tools/simulator.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-05-05 03:22:05 +0000
committerGerrit Code Review <review@openstack.org>2016-05-05 03:22:06 +0000
commite2b57bb590d8be47f12adc7d6058293f835683d9 (patch)
treef1175cff0b1a5dd5baac3b7ab9243bb622c585ca /tools/simulator.py
parent2a6f7c591001c44dcf70998553ea65cae2d1b459 (diff)
parent782ab770cf55d9856a9917ace5924c9d2732af99 (diff)
downloadoslo-messaging-e2b57bb590d8be47f12adc7d6058293f835683d9.tar.gz
Merge "Simulator: align stats to whole seconds"
Diffstat (limited to 'tools/simulator.py')
-rwxr-xr-xtools/simulator.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/simulator.py b/tools/simulator.py
index a62def5..36066d7 100755
--- a/tools/simulator.py
+++ b/tools/simulator.py
@@ -116,7 +116,10 @@ class MessageStatsCollector(object):
self.label = label
self.buffer = [] # buffer to store messages during report interval
self.series = [] # stats for every report interval
- threading.Timer(1.0, self.monitor).start() # schedule in a second
+
+ now = time.time()
+ diff = int(now) - now + 1 # align start to whole seconds
+ threading.Timer(diff, self.monitor).start() # schedule in a second
def monitor(self):
global IS_RUNNING
@@ -440,6 +443,11 @@ def send_messages(client_id, client_builder, messages_count, duration):
client = client_builder()
CLIENTS.append(client)
+ # align message sending closer to whole seconds
+ now = time.time()
+ diff = int(now) - now + 1
+ time.sleep(diff)
+
if duration:
with timeutils.StopWatch(duration) as stop_watch:
while not stop_watch.expired() and IS_RUNNING: