[Erp5-report] r27799 - /erp5/trunk/utils/analyze.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jun 25 17:36:18 CEST 2009


Author: kazuhiko
Date: Thu Jun 25 17:36:17 2009
New Revision: 27799

URL: http://svn.erp5.org?rev=27799&view=rev
Log:
display current/old information for each class.

Modified:
    erp5/trunk/utils/analyze.py

Modified: erp5/trunk/utils/analyze.py
URL: http://svn.erp5.org/erp5/trunk/utils/analyze.py?rev=27799&r1=27798&r2=27799&view=diff
==============================================================================
--- erp5/trunk/utils/analyze.py [utf8] (original)
+++ erp5/trunk/utils/analyze.py [utf8] Thu Jun 25 17:36:17 2009
@@ -23,6 +23,10 @@
         self.CBYTES = 0
         self.FOIDS = 0
         self.FBYTES = 0
+        self.COIDSMAP = {}
+        self.CBYTESMAP = {}
+        self.FOIDSMAP = {}
+        self.FBYTESMAP = {}
 
 def shorten(s, n):
     l = len(s)
@@ -45,21 +49,24 @@
            (rep.DBYTES * 1.0 / rep.TIDS))
 
     print "Types used:"
-    fmt = "%-46s %7s %9s %6s %7s"
-    fmtp = "%-46s %7d %9d %5.1f%% %7.2f" # per-class format
+    fmt = "%-46s %7s %9s %6s %7s %7s %9s %7s %9s"
+    fmtp = "%-46s %7d %9d %5.1f%% %7.2f %7d %9d %7d %9d" # per-class format
     fmts = "%46s %7d %8d %5.1f%% %7.2f" # summary format
-    print fmt % ("Class Name", "Count", "TBytes", "Pct", "AvgSize")
-    print fmt % ('-'*46, '-'*7, '-'*9, '-'*5, '-'*7)
+    print fmt % ("Class Name", "T.Count", "T.Bytes", "Pct", "AvgSize",
+                 "C.Count", "C.Bytes", "O.Count", "O.Bytes")
+    print fmt % ('-'*46, '-'*7, '-'*9, '-'*5, '-'*7, '-'*7, '-'*9, '-'*7, '-'*9)
     typemap = rep.TYPEMAP.keys()
-    typemap.sort(lambda a,b: cmp(rep.TYPESIZE[a], rep.TYPESIZE[b]))
+    typemap.sort(key=lambda a:rep.TYPESIZE[a])
     cumpct = 0.0
     for t in typemap:
         pct = rep.TYPESIZE[t] * 100.0 / rep.DBYTES
         cumpct += pct
         print fmtp % (shorten(t, 46), rep.TYPEMAP[t], rep.TYPESIZE[t],
-                      pct, rep.TYPESIZE[t] * 1.0 / rep.TYPEMAP[t])
+                      pct, rep.TYPESIZE[t] * 1.0 / rep.TYPEMAP[t],
+                      rep.COIDSMAP[t], rep.CBYTESMAP[t],
+                      rep.FOIDSMAP.get(t, 0), rep.FBYTESMAP.get(t, 0))
 
-    print fmt % ('='*46, '='*7, '='*9, '='*5, '='*7)
+    print fmt % ('='*46, '='*7, '='*9, '='*5, '='*7, '='*7, '='*9, '='*7, '='*9)
     print "%46s %7d %9s %6s %6.2f" % ('Total Transactions', rep.TIDS, ' ',
         ' ', rep.DBYTES * 1.0 / rep.TIDS)
     print fmts % ('Total Records', rep.OIDS, rep.DBYTES, cumpct,
@@ -105,6 +112,8 @@
             report.USEDMAP[oid] = size
             report.COIDS += 1
             report.CBYTES += size
+            report.COIDSMAP[type] = report.COIDSMAP.get(type, 0) + 1
+            report.CBYTESMAP[type] = report.CBYTESMAP.get(type, 0) + size
         else:
             type = report.OIDMAP[oid]
             fsize = report.USEDMAP[oid]
@@ -113,6 +122,9 @@
             report.FOIDS += 1
             report.FBYTES += fsize
             report.CBYTES += size - fsize
+            report.FOIDSMAP[type] = report.FOIDSMAP.get(type, 0) + 1
+            report.FBYTESMAP[type] = report.FBYTESMAP.get(type, 0) + fsize
+            report.CBYTESMAP[type] = report.CBYTESMAP.get(type, 0) + size - fsize
         report.TYPEMAP[type] = report.TYPEMAP.get(type, 0) + 1
         report.TYPESIZE[type] = report.TYPESIZE.get(type, 0) + size
     except Exception, err:




More information about the Erp5-report mailing list