[Python-checkins] r75464 - sandbox/trunk/ccbench/ccbench.py

antoine.pitrou python-checkins at python.org
Sat Oct 17 17:29:23 CEST 2009


Author: antoine.pitrou
Date: Sat Oct 17 17:29:23 2009
New Revision: 75464

Log:
Try to improve the latency test a bit



Modified:
   sandbox/trunk/ccbench/ccbench.py

Modified: sandbox/trunk/ccbench/ccbench.py
==============================================================================
--- sandbox/trunk/ccbench/ccbench.py	(original)
+++ sandbox/trunk/ccbench/ccbench.py	Sat Oct 17 17:29:23 2009
@@ -242,9 +242,15 @@
     sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     _time = time.time
     _sleep = time.sleep
+    def _ping():
+        _sendto(sock, "%r\n" % _time(), addr)
+    # The first ping signals the parent process that we are ready.
+    _ping()
+    # We give the parent a bit of time to notice.
+    _sleep(1.0)
     for i in range(nb_pings):
         _sleep(interval)
-        _sendto(sock, "%r\n" % _time(), addr)
+        _ping()
     _sendto(sock, LAT_END + "\n", addr)
 
 def run_latency_client(**kwargs):
@@ -294,7 +300,7 @@
     # unblocking the background threads.
     chunks = []
     process = run_latency_client(addr=sock.getsockname(),
-                                 nb_pings=nb_pings + 1, interval=interval)
+                                 nb_pings=nb_pings, interval=interval)
     s = _recv(sock, 4096)
     _time = time.time
 


More information about the Python-checkins mailing list