summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDavanum Srinivas <davanum@gmail.com>2016-03-21 10:05:21 -0400
committerDavanum Srinivas <davanum@gmail.com>2016-03-21 21:03:14 -0400
commit38b907a1302e53795f89598757536d93b29edc7a (patch)
treef58099013a48948042bf6076f44a2de12e5ae6a3 /tools
parent5ad18f73c507ae3d98f0fb5f162c2e974840c94e (diff)
downloadoslo-messaging-38b907a1302e53795f89598757536d93b29edc7a.tar.gz
Support python3 in simulator.py
Tested with: python3 simulator.py --url \ rabbit://stackrabbit:flopsymopsy@localhost:5672/ notify-server python3 simulator.py --url \ rabbit://stackrabbit:flopsymopsy@localhost:5672/ notify-client -m 1000 and: python3 simulator.py --url \ rabbit://stackrabbit:flopsymopsy@localhost:5672/ rpc-server python3 simulator.py --url \ rabbit://stackrabbit:flopsymopsy@localhost:5672/ rpc-client -m 1000 Change-Id: I1f8bb964aef23867a651e192dc355635e36f78a1
Diffstat (limited to 'tools')
-rwxr-xr-xtools/simulator.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/tools/simulator.py b/tools/simulator.py
index 962b559..c12bdac 100755
--- a/tools/simulator.py
+++ b/tools/simulator.py
@@ -64,7 +64,7 @@ def init_random_generator():
ranges = collections.defaultdict(int)
for msg_length in data:
- range_start = ((msg_length / DISTRIBUTION_BUCKET_SIZE) *
+ range_start = ((msg_length // DISTRIBUTION_BUCKET_SIZE) *
DISTRIBUTION_BUCKET_SIZE + 1)
ranges[range_start] += 1
@@ -121,7 +121,7 @@ class MessageStatsCollector(object):
count = len(self.buffer)
size = 0
- min_latency = sys.maxint
+ min_latency = sys.maxsize
max_latency = 0
sum_latencies = 0
@@ -168,10 +168,10 @@ class MessageStatsCollector(object):
def calc_stats(label, *collectors):
count = 0
size = 0
- min_latency = sys.maxint
+ min_latency = sys.maxsize
max_latency = 0
sum_latencies = 0
- start = sys.maxint
+ start = sys.maxsize
end = 0
for point in itertools.chain(*(c.get_series() for c in collectors)):
@@ -365,7 +365,8 @@ def generate_messages(messages_count):
for i in range(messages_count):
length = RANDOM_GENERATOR()
- msg = ''.join(random.choice(string.lowercase) for x in range(length))
+ msg = ''.join(random.choice(
+ string.ascii_lowercase) for x in range(length))
MESSAGES.append(msg)
LOG.info("Messages has been prepared")
@@ -401,7 +402,7 @@ def spawn_rpc_clients(threads, transport, targets, wait_after_msg, timeout,
p = eventlet.GreenPool(size=threads)
targets = itertools.cycle(targets)
for i in range(0, threads):
- target = targets.next()
+ target = next(targets)
LOG.debug("starting RPC client for target %s", target)
client_builder = functools.partial(RPCClient, i, transport, target,
timeout, is_cast, wait_after_msg)