[Checkins] SVN: zodbshootout/trunk/ Added the --object-size parameter.

Shane Hathaway shane at hathawaymix.org
Tue Feb 1 07:01:51 EST 2011


Log message for revision 120035:
  Added the --object-size parameter.
  
  

Changed:
  U   zodbshootout/trunk/CHANGES.txt
  U   zodbshootout/trunk/buildout.cfg
  U   zodbshootout/trunk/src/zodbshootout/main.py

-=-
Modified: zodbshootout/trunk/CHANGES.txt
===================================================================
--- zodbshootout/trunk/CHANGES.txt	2011-02-01 07:26:03 UTC (rev 120034)
+++ zodbshootout/trunk/CHANGES.txt	2011-02-01 12:01:50 UTC (rev 120035)
@@ -1,7 +1,7 @@
-Next Release
-------------
+0.4 (2011-02-01)
+----------------
 
-- ...
+- Added the --object-size parameter.
 
 0.3 (2010-06-19)
 ----------------

Modified: zodbshootout/trunk/buildout.cfg
===================================================================
--- zodbshootout/trunk/buildout.cfg	2011-02-01 07:26:03 UTC (rev 120034)
+++ zodbshootout/trunk/buildout.cfg	2011-02-01 12:01:50 UTC (rev 120035)
@@ -15,6 +15,7 @@
 
 [buildout]
 develop = .
+	/home/shane/svn/relstorage/trunk
 base-parts =
     postgresql
     postgresqlinit

Modified: zodbshootout/trunk/src/zodbshootout/main.py
===================================================================
--- zodbshootout/trunk/src/zodbshootout/main.py	2011-02-01 07:26:03 UTC (rev 120034)
+++ zodbshootout/trunk/src/zodbshootout/main.py	2011-02-01 12:01:50 UTC (rev 120035)
@@ -25,6 +25,7 @@
 from zodbshootout.fork import ChildProcessError
 from zodbshootout.fork import distribute
 from zodbshootout.fork import run_in_child
+import cPickle
 import optparse
 import os
 import sys
@@ -51,13 +52,24 @@
     """A trivial persistent object"""
     attr = 1
 
+    def __init__(self, data):
+        self.data = data
+
+
+# Estimate the size of a minimal PObject stored in ZODB.
+pobject_base_size = (
+    len(cPickle.dumps(PObject)) + len(cPickle.dumps(PObject(''))))
+
+
 class SpeedTest:
 
-    def __init__(self, concurrency, objects_per_txn, profile_dir=None):
+    def __init__(self, concurrency, objects_per_txn, object_size,
+            profile_dir=None):
         self.concurrency = concurrency
         self.objects_per_txn = objects_per_txn
+        data = 'x' * max(0, object_size - pobject_base_size)
         self.data_to_store = dict(
-            (n, PObject()) for n in range(objects_per_txn))
+            (n, PObject(data)) for n in range(objects_per_txn))
         self.profile_dir = profile_dir
         self.contender_name = None
         self.rep = 0  # repetition number
@@ -259,6 +271,10 @@
         help="Object counts to use, separated by commas (default 1000)",
         )
     parser.add_option(
+        "-s", "--object-size", dest="object_size", default="115",
+        help="Size of each object in bytes (estimated, default approx. 115)",
+        )
+    parser.add_option(
         "-c", "--concurrency", dest="concurrency", default="2",
         help="Concurrency levels to use, separated by commas (default 2)",
         )
@@ -274,6 +290,7 @@
 
     object_counts = [int(x.strip())
                      for x in options.counts.split(',')]
+    object_size = max(int(options.object_size), pobject_base_size)
     concurrency_levels = [int(x.strip())
                           for x in options.concurrency.split(',')]
     profile_dir = options.profile_dir
@@ -306,11 +323,14 @@
     try:
         for objects_per_txn in object_counts:
             for concurrency in concurrency_levels:
-                speedtest = SpeedTest(concurrency, objects_per_txn, profile_dir)
+                speedtest = SpeedTest(
+                    concurrency, objects_per_txn, object_size, profile_dir)
                 for contender_name, db in contenders:
                     print >> sys.stderr, (
-                        'Testing %s with objects_per_txn=%d and concurrency=%d'
-                        % (contender_name, objects_per_txn, concurrency))
+                        'Testing %s with objects_per_txn=%d, object_size=%d, '
+                        'and concurrency=%d'
+                        % (contender_name, objects_per_txn, object_size,
+                            concurrency))
                     db_factory = db.open
                     key = (objects_per_txn, concurrency, contender_name)
 



More information about the checkins mailing list