[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - TextIndexNG.py:1.2.2.32
Andreas Jung
andreas@digicool.com
Wed, 13 Feb 2002 19:31:04 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv24223
Modified Files:
Tag: ajung-textindexng-branch
TextIndexNG.py
Log Message:
added summary function for timer class for detailed statistics
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/TextIndexNG.py 1.2.2.31 => 1.2.2.32 ===
self.ts = time.time()
self.verbose = verbose
+ self.d = {}
def __call__(self,s):
diff = time.time() - self.ts
self.ts = time.time()
+ self.d[s] = diff
+
if self.verbose:
print "%s: %5.5lf" % (s, diff)
+
+ def printStats(self):
+
+ total = 0.0
+ for t in self.d.values(): total=total + t
+
+ keys = self.d.keys()
+ keys.sort()
+
+ print "total: %5.5lf secs" % total
+ for k,v in self.d.items():
+ print "%-20s %5.4lf secs (%5.2lf %%) " % (k,v,100.0*v/total)
+
@@ -166,6 +182,8 @@
if verbose: self.debugOn()
else: self.debugOff()
+ self.verbose = verbose
+
self.timed_statistics = timed_statistics
self.clear()
@@ -440,6 +458,8 @@
# insert backward entries
self.insertBackwardEntries(widLst,documentId)
T("BackwardEntries")
+
+ if self.verbose: T.printStats()
return len(widLst)