summaryrefslogtreecommitdiff
path: root/perf
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@fastmq.com>2009-09-09 11:07:48 +0200
committerMartin Sustrik <sustrik@fastmq.com>2009-09-09 11:07:48 +0200
commit305b81dbdf63ab1b66733a330b2c64a980712b8b (patch)
tree534e3213486682b8372f3e9fb72064d29029124d /perf
parent4d07d7cabe1a865812cf5d95a84557880e3c3096 (diff)
higher precision time measurement in python perf tests
Diffstat (limited to 'perf')
-rw-r--r--perf/python/local_thr.py8
-rw-r--r--perf/python/remote_lat.py11
2 files changed, 10 insertions, 9 deletions
diff --git a/perf/python/local_thr.py b/perf/python/local_thr.py
index 6113c82..0d142cf 100644
--- a/perf/python/local_thr.py
+++ b/perf/python/local_thr.py
@@ -18,7 +18,7 @@
#
import sys
-from datetime import datetime
+import time
import libpyzmq
def main ():
@@ -41,15 +41,15 @@ def main ():
msg = s.recv ()
assert len (msg) == message_size
- start = datetime.now ()
+ start = time.clock ()
for i in range (1, message_count):
msg = s.recv ()
assert len (msg) == message_size
- end = datetime.now()
+ end = time.clock ()
- elapsed = (end - start).seconds * 1000000 + (end - start).microseconds
+ elapsed = (end - start) * 1000000
if elapsed == 0:
elapsed = 1
throughput = (1000000.0 * float (message_count)) / float (elapsed)
diff --git a/perf/python/remote_lat.py b/perf/python/remote_lat.py
index f2ee04a..29bd550 100644
--- a/perf/python/remote_lat.py
+++ b/perf/python/remote_lat.py
@@ -18,7 +18,7 @@
#
import sys
-from datetime import datetime
+import time
import libpyzmq
def main ():
@@ -40,16 +40,17 @@ def main ():
msg = ''.join ([' ' for n in range (0, message_size)])
- start = datetime.now ()
+ start = time.clock ()
for i in range (0, roundtrip_count):
s.send (msg)
msg = s.recv ()
assert len (msg) == message_size
- end = datetime.now ()
- delta = (end - start).microseconds + 1000000 * (end - start).seconds
- latency = float (delta) / roundtrip_count / 2
+ end = time.clock ()
+
+ elapsed = (end - start) * 1000000
+ latency = elapsed / roundtrip_count / 2
print "message size: %.0f [B]" % (message_size, )
print "roundtrip count: %.0f" % (roundtrip_count, )