[Zodb-checkins] CVS: ZODB3/ZEO - stats.py:1.13

Guido van Rossum guido@python.org
Sat, 7 Sep 2002 22:38:18 -0400


Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv5976

Modified Files:
	stats.py 
Log Message:
(Apologies to Jeremy.  One 'h' is enough in the getopt argument list. :-)

Sort options alphabetically.  Remove dependency between -S, -q and -v
options (-S no longer disables -q and enables -v).  Remove dependency
between -S and -h (histogram is printed regardless of dostats).


=== ZODB3/ZEO/stats.py 1.12 => 1.13 ===
--- ZODB3/ZEO/stats.py:1.12	Sat Sep  7 22:20:30 2002
+++ ZODB3/ZEO/stats.py	Sat Sep  7 22:38:17 2002
@@ -14,12 +14,12 @@
 ##############################################################################
 """Trace file statistics analyzer.
 
-Usage: stats.py [-h] [-i interval] [-q] [-v] [-S] tracefile
+Usage: stats.py [-h] [-i interval] [-q] [-S] [-v] tracefile
 -h: print histogram
 -i: summarizing interval in minutes (default 15; max 60)
--q: quiet; don't print sommaries
+-q: quiet; don't print summaries
+-S: don't print statistics
 -v: verbose; print each record
--S: don't print statistics (turns off -q)
 """
 
 """File format:
@@ -66,11 +66,13 @@
     print_histogram = 0
     interval = 900 # Every 15 minutes
     try:
-        opts, args = getopt.getopt(sys.argv[1:], "hi:qvSh")
+        opts, args = getopt.getopt(sys.argv[1:], "hi:qSv")
     except getopt.error, msg:
         usage(msg)
         return 2
     for o, a in opts:
+        if o == '-h':
+            print_histogram = 1
         if o == "-i":
             interval = int(60 * float(a))
             if interval <= 0:
@@ -80,14 +82,10 @@
         if o == "-q":
             quiet = 1
             verbose = 0
-        if o == "-v":
-            verbose = 1
         if o == "-S":
             dostats = 0
+        if o == "-v":
             verbose = 1
-            quiet = 0
-        if o == '-h':
-            print_histogram = 1
     if len(args) != 1:
         usage("exactly one file argument required")
         return 2
@@ -225,25 +223,27 @@
                 addcommas(bycode.get(code, 0)),
                 code,
                 explain.get(code) or "*** unknown code ***")
-        if print_histogram:
-            print
-            print "Histogram of object load frequency"
-            total = len(oids)
-            s = addcommas(total)
-            print "Unique oids: %s" % addcommas(total)
-            print "Total loads: %s" % addcommas(total_loads)
-            width = max(len(s), len("objects"))
-            fmt = "%5d %" + str(width) + "s %3d%% %5.1f%% %4d%%"
-            hdr = "%5s %" + str(width) + "s %4s %6s %5s"
-            print hdr % ("loads", "objects", "%obj", "%load", "%cum")
-            cum = 0.0
-            for binsize, count in histogram(oids):
-                obj_percent = 100 * count / total
-                load_percent = 1000 * count * binsize / total_loads
-                load_percent /= 10.
-                cum += load_percent
-                print fmt % (binsize, addcommas(count),
-                             obj_percent, load_percent, cum)
+
+    # Print histogram
+    if print_histogram:
+        print
+        print "Histogram of object load frequency"
+        total = len(oids)
+        s = addcommas(total)
+        print "Unique oids: %s" % addcommas(total)
+        print "Total loads: %s" % addcommas(total_loads)
+        width = max(len(s), len("objects"))
+        fmt = "%5d %" + str(width) + "s %3d%% %5.1f%% %4d%%"
+        hdr = "%5s %" + str(width) + "s %4s %6s %5s"
+        print hdr % ("loads", "objects", "%obj", "%load", "%cum")
+        cum = 0.0
+        for binsize, count in histogram(oids):
+            obj_percent = 100 * count / total
+            load_percent = 1000 * count * binsize / total_loads
+            load_percent /= 10.
+            cum += load_percent
+            print fmt % (binsize, addcommas(count),
+                         obj_percent, load_percent, cum)
 
 def dumpbyinterval(byinterval, h0, he):
     loads = 0