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

antoine.pitrou python-checkins at python.org
Fri Oct 16 00:20:19 CEST 2009


Author: antoine.pitrou
Date: Fri Oct 16 00:20:18 2009
New Revision: 75443

Log:
Tweak params 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	Fri Oct 16 00:20:18 2009
@@ -78,7 +78,7 @@
         arg = f.read(5000) * 3
 
     def compress(s):
-        zlib.decompress(zlib.compress(s))
+        zlib.decompress(zlib.compress(s, 5))
     return compress, (arg, )
 
 
@@ -91,7 +91,7 @@
         self.args = args
     
     def __call__(self, start_time, min_duration, end_event, do_yield=True):
-        step = 100
+        step = 20
         niters = 0
         duration = 0.0
         _time = time.time
@@ -113,9 +113,9 @@
             if duration >= min_duration:
                 end_event.set()
                 return niters, duration
-            if t2 - t1 < 0.02:
+            if t2 - t1 < 0.01:
                 # Minimize interference of measurement on overall runtime
-                step *= 2
+                step = step * 3 // 2
             else:
                 if do_yield:
                     # OS scheduling of Python threads is sometimes so bad that we
@@ -128,6 +128,9 @@
 def run_throughput_test(func, args, nthreads):
     assert nthreads >= 1
     
+    # Warm up
+    func(*args)
+
     results = []
     loop = TimedLoop(func, args)
     end_event = threading.Event()
@@ -176,9 +179,8 @@
         baseline_speed = None
         while nthreads <= max_threads:
             results = run_throughput_test(func, args, nthreads)
-            # The max duration is assumed to be more representative of
-            # the total duration than the average would, especially with
-            # imperfect scheduling.
+            # Taking the max duration rather than average gives pessimistic
+            # results rather than optimistic.
             speed = sum(r[0] for r in results) / max(r[1] for r in results)
             print("threads=%d: %d" % (nthreads, speed), end="")
             if baseline_speed is None:


More information about the Python-checkins mailing list