[Zope-Checkins] SVN: Zope/trunk/src/Products/ZCatalog/ Move the len() calculation into the stop watch class

Hanno Schlichting hannosch at hannosch.eu
Sun Aug 1 15:17:50 EDT 2010


Log message for revision 115348:
  Move the len() calculation into the stop watch class
  

Changed:
  U   Zope/trunk/src/Products/ZCatalog/Catalog.py
  U   Zope/trunk/src/Products/ZCatalog/report.py

-=-
Modified: Zope/trunk/src/Products/ZCatalog/Catalog.py
===================================================================
--- Zope/trunk/src/Products/ZCatalog/Catalog.py	2010-08-01 18:35:58 UTC (rev 115347)
+++ Zope/trunk/src/Products/ZCatalog/Catalog.py	2010-08-01 19:17:49 UTC (rev 115348)
@@ -528,14 +528,14 @@
                 # once we don't need to support the "return everything" case
                 # anymore
                 if r is not None and not r:
-                    cr.split(i, 0)
+                    cr.split(i, None)
                     return LazyCat([])
-                cr.split(i, len(r))
+                cr.split(i, r)
                 w, rs = weightedIntersection(rs, r)
                 if not rs:
                     break
             else:
-                cr.split(i, 0)
+                cr.split(i, None)
 
         cr.stop()
 

Modified: Zope/trunk/src/Products/ZCatalog/report.py
===================================================================
--- Zope/trunk/src/Products/ZCatalog/report.py	2010-08-01 18:35:58 UTC (rev 115347)
+++ Zope/trunk/src/Products/ZCatalog/report.py	2010-08-01 19:17:49 UTC (rev 115348)
@@ -117,7 +117,7 @@
         self.init()
         self.start_time = time.time()
 
-    def split(self, label, result_length=None):
+    def split(self, label, result=None):
         current = time.time()
         start_time, stop_time = self.interim.get(label, (None, None))
 
@@ -125,8 +125,12 @@
             self.interim[label] = (current, None)
             return
 
+        length = 0
+        if result is not None:
+            # TODO: calculating the length can be expensive
+            length = len(result)
         self.interim[label] = (start_time, current)
-        self.res.append((label, current - start_time, result_length))
+        self.res.append((label, current - start_time, length))
 
     def stop(self):
         self.end_time = time.time()



More information about the Zope-Checkins mailing list