[Zodb-checkins] CVS: Packages/ZEO - speed.py:1.4

jeremy@digicool.com jeremy@digicool.com
Tue, 8 May 2001 19:26:58 -0400 (EDT)


Update of /cvs-repository/Packages/ZEO/tests
In directory korak:/tmp/cvs-serv23717/tests

Modified Files:
	speed.py 
Log Message:
Print mean, min, and max for summary.
Also print # conflicts for each test (appears to be zero).



--- Updated File speed.py in package Packages/ZEO --
--- speed.py	2001/05/01 22:41:26	1.3
+++ speed.py	2001/05/08 23:26:57	1.4
@@ -151,6 +151,7 @@
     for j in range(nrep):
         for r in 1, 10, 100, 1000:
             t = time.time()
+            conflicts = 0
             
             jar = db.open()
             while 1:
@@ -171,7 +172,7 @@
                         setattr(p, str(i), v)
                     get_transaction().commit()
                 except ConflictError:
-                    pass
+                    conflicts = conflicts + 1
                 else:
                     break
             jar.close()
@@ -179,10 +180,11 @@
             t = time.time() - t
             if detailed:
                 if threadno is None:
-                    print "%s\t%s\t%.4f" % (j, r, t)
+                    print "%s\t%s\t%.4f\t%d" % (j, r, t, conflicts)
                 else:
-                    print "%s\t%s\t%.4f\t%d" % (j, r, t, threadno)
-            results[r] = results[r] + t
+                    print "%s\t%s\t%.4f\t%d\t%d" % (j, r, t, conflicts,
+                                                    threadno)
+            results[r].append((t, conflicts))
             rt=d=p=v=None # release all references
             if minimize:
                 time.sleep(3)
@@ -238,7 +240,7 @@
                cache_deactivate_after=6000,)
 
     print "Beginning work..."
-    results={1:0, 10:0, 100:0, 1000:0}
+    results={1:[], 10:[], 100:[], 1000:[]}
     if threads > 1:
         import threading
         l = [threading.Thread(target=work,
@@ -259,9 +261,17 @@
 
     if detailed:
         print '-'*24
+    print "num\tmean\tmin\tmax"
     for r in 1, 10, 100, 1000:
-        t=results[r]/(nrep * threads)
-        print "mean:\t%s\t%.4f\t%.4f (s/o)" % (r, t, t/r)
+        times = [time for time, conf in results[r]]
+        t = mean(times)
+        print "%d\t%.4f\t%.4f\t%.4f" % (r, t, min(times), max(times))
+
+def mean(l):
+    tot = 0
+    for v in l:
+        tot = tot + v
+    return tot / len(l)
     
 ##def compress(s):
 ##    c = zlib.compressobj()