[Zodb-checkins] CVS: StandaloneZODB/Tools - timeiter.py:1.1.2.11

Guido van Rossum guido@python.org
Sun, 20 Jan 2002 17:23:58 -0500


Update of /cvs-repository/StandaloneZODB/Tools
In directory cvs.zope.org:/tmp/cvs-serv32192

Modified Files:
      Tag: Standby-branch
	timeiter.py 
Log Message:
Add -t/--timestamps option, which prints tids as timestamps.


=== StandaloneZODB/Tools/timeiter.py 1.1.2.10 => 1.1.2.11 ===
         Turn on specialized profiling.
 
+    -t/--timestamps
+        Print tids as timestamps.
+
     -T/--storage_types
         Print all the recognized storage types and exit.
 
@@ -93,10 +96,10 @@
     try:
         opts, args = getopt.getopt(
             sys.argv[1:],
-            'hvo:pm:k:D:S:T',
+            'hvo:pm:k:D:S:Tt',
             ['help', 'verbose',
              'output=', 'profile', 'storage_types',
-             'max=', 'skip=', 'dtype=', 'stype='])
+             'max=', 'skip=', 'dtype=', 'stype=', 'timestamps'])
     except getopt.error, msg:
         error(2, msg)
 
@@ -108,6 +111,7 @@
         profilep = 0
         maxtxn = -1
         skiptxn = -1
+        timestamps = 0
 
     options = Options()
 
@@ -134,6 +138,8 @@
             options.maxtxn = int(arg)
         elif opt in ('-k', '--skip'):
             options.skiptxn = int(arg)
+        elif opt in ('-t', '--timestamps'):
+            options.timestamps = 1
 
     args = list(args)
 
@@ -203,10 +209,16 @@
     prevrevids = {}
     counter = 0
     skipper = 0
-    print "%4s. %20s %6s %8s %6s %6s %6s %6s %6s" % (
-        "NUM", "TRANSACTION ID", "OBJS", "BYTES",
-        # Does anybody know what these times mean?
-        "t4-t0", "t1-t0", "t2-t1", "t3-t2", "t4-t3")
+    if options.timestamps:
+        print "%4s. %26s %6s %8s %5s %5s %5s %5s %5s" % (
+            "NUM", "TID AS TIMESTAMP", "OBJS", "BYTES",
+            # Does anybody know what these times mean?
+            "t4-t0", "t1-t0", "t2-t1", "t3-t2", "t4-t3")
+    else:
+        print "%4s. %20s %6s %8s %6s %6s %6s %6s %6s" % (
+            "NUM", "TRANSACTION ID", "OBJS", "BYTES",
+            # Does anybody know what these times mean?
+            "t4-t0", "t1-t0", "t2-t1", "t3-t2", "t4-t3")
     for txn in srcdb.iterator():
         skipper += 1
         if skipper <= options.skiptxn:
@@ -277,9 +289,16 @@
 	    largest_txn_in_objects = objects
 	if size > largest_txn_in_size:
 	    largest_txn_in_size = size
-        print >> outfp, "%4d. %20d %6d %8d %6.4f %6.4f %6.4f %6.4f %6.4f" % (
-            skipper, utils.U64(tid), objects, size,
-            t4-t0, t1-t0, t2-t1, t3-t2, t4-t3)
+        if options.timestamps:
+            tidstr = str(TimeStamp(tid))
+            if tidstr[18] == '.':
+                tidstr = tidstr[:17] + '0' + tidstr[17:]
+            format = "%4d. %26s %6d %8d %5.3f %5.3f %5.3f %5.3f %5.3f"
+        else:
+            tidstr = utils.U64(tid)
+            format = "%4d. %20s %6d %8d %6.4f %6.4f %6.4f %6.4f %6.4f"
+        print >> outfp, format % (skipper, tidstr, objects, size,
+                                  t4-t0, t1-t0, t2-t1, t3-t2, t4-t3)
         total_pickle_size += size
         total_object_count += objects