[Zodb-checkins] CVS: StandaloneZODB/bsddb3Storage/bsddb3Storage/tests - timeiter.py:1.2

Barry Warsaw barry@wooz.org
Thu, 1 Nov 2001 12:17:26 -0500


Update of /cvs-repository/StandaloneZODB/bsddb3Storage/bsddb3Storage/tests
In directory cvs.zope.org:/tmp/cvs-serv20298

Modified Files:
	timeiter.py 
Log Message:
Added -k/--skip option.

Also, move the opening of the output and log files above the opening
of the storages so there's a closer link between that and the
try/finally that closes closes the storages.


=== StandaloneZODB/bsddb3Storage/bsddb3Storage/tests/timeiter.py 1.1 => 1.2 ===
         Stop after committing txncount transactions.
 
+    -k txncount
+    --skip=txncount
+        Skip the first txncount transactions.
+
     -p/--profile
         Turn on specialized profiling.
 
@@ -64,10 +68,10 @@
 
 def main():
     try:
-        opts, args = getopt.getopt(sys.argv[1:], 'hs:d:qo:l:pm:',
+        opts, args = getopt.getopt(sys.argv[1:], 'hs:d:qo:l:pm:k:',
                                    ['help', 'source=', 'dest=', 'quiet',
                                     'output=', 'logfile=', 'profile',
-                                    'max='])
+                                    'max=', 'skip='])
     except getopt.error, msg:
         usage(1, msg)
 
@@ -79,6 +83,7 @@
         logfile = None
         profilep = 0
         maxtxn = -1
+        skiptxn = -1
 
     options = Options()
 
@@ -99,6 +104,8 @@
             options.profilep = 1
         elif opt in ('-m', '--max'):
             options.maxtxn = int(arg)
+        elif opt in ('-k', '--skip'):
+            options.skiptxn = int(arg)
 
     if args:
         usage(1)
@@ -106,6 +113,26 @@
     if not options.source or not options.dest:
         usage(1, 'Source and destination databases must be provided')
 
+    # Open the output file
+    if options.outfile is None:
+        options.outfp = sys.stdout
+        options.outclosep = 0
+    else:
+        options.outfp = open(options.outfile, 'w')
+        options.outclosep = 1
+
+    # Open the logfile
+    if options.logfile is None:
+        options.logfp = sys.stdout
+        options.logclosep = 0
+    else:
+        options.logfp = open(options.logfile, 'w')
+        options.logclosep = 1
+
+    # Print a comment, this is a hack
+    print >> options.outfp, '# FS->BDB 3.3.11'
+    print >> options.outfp, '#', time.ctime()
+
     print >>sys.stderr, 'Opening source FileStorage...'
     t0 = time.time()
     srcdb = FileStorage(options.source, read_only=1)
@@ -119,6 +146,7 @@
     dstdb = Full(options.dest)
     t1 = time.time()
     print >>sys.stderr, 'Opening destination BDB done. %s seconds' % (t1-t0)
+
 #
 # Uncomment this section to do a FS->FS migration
 #
@@ -129,26 +157,6 @@
 ##    print >>sys.stderr, 'Opening destination FileStorage done. %s seconds' % (
 ##        t1-t0)
 
-    # Open the output file
-    if options.outfile is None:
-        options.outfp = sys.stdout
-        options.outclosep = 0
-    else:
-        options.outfp = open(options.outfile, 'w')
-        options.outclosep = 1
-
-    # Open the logfile
-    if options.logfile is None:
-        options.logfp = sys.stdout
-        options.logclosep = 0
-    else:
-        options.logfp = open(options.logfile, 'w')
-        options.logclosep = 1
-
-    # Print a comment, this is a hack
-    print >> options.outfp, '# FS->BDB 3.3.11'
-    print >> options.outfp, '#', time.ctime()
-
     try:
         t0 = time.time()
         doit(srcdb, dstdb, options)
@@ -179,7 +187,11 @@
     ok = 1
     prevrevids = {}
     counter = 0
+    skipper = 0
     for txn in srcdb.iterator():
+        skipper += 1
+        if skipper <= options.skiptxn:
+            continue
         counter += 1
         if counter > options.maxtxn > 0:
             break