[Zope-Checkins] SVN: Zope/trunk/src/Products/ZCatalog/plan.py Remove some dead code and protect access to the benchmark entry

Hanno Schlichting hannosch at hannosch.eu
Sun Aug 1 17:56:53 EDT 2010


Log message for revision 115357:
  Remove some dead code and protect access to the benchmark entry
  

Changed:
  U   Zope/trunk/src/Products/ZCatalog/plan.py

-=-
Modified: Zope/trunk/src/Products/ZCatalog/plan.py
===================================================================
--- Zope/trunk/src/Products/ZCatalog/plan.py	2010-08-01 21:51:54 UTC (rev 115356)
+++ Zope/trunk/src/Products/ZCatalog/plan.py	2010-08-01 21:56:53 UTC (rev 115357)
@@ -182,7 +182,8 @@
         # remember index's hits, search time and calls
         benchmark = self.benchmark()
         if name not in benchmark:
-            benchmark[name] = Benchmark(num=length, duration=dt, hits=1)
+            with PRIORITYMAP_LOCK:
+                benchmark[name] = Benchmark(num=length, duration=dt, hits=1)
         else:
             num, duration, hits = benchmark[name]
             num = int(((num * hits) + length) / float(hits + 1))
@@ -191,7 +192,8 @@
             if hits % REFRESH_RATE == 0:
                 hits = 0
             hits += 1
-            benchmark[name] = Benchmark(num, duration, hits)
+            with PRIORITYMAP_LOCK:
+                benchmark[name] = Benchmark(num, duration, hits)
 
     def stop(self):
         self.end_time = time.time()
@@ -203,20 +205,6 @@
         with PRIORITYMAP_LOCK:
             PRIORITYMAP[key] = benchmark
 
-        # calculate mean time of search
-        stats = getattr(self.catalog, '_v_stats', None)
-        if stats is None:
-            stats = self.catalog._v_stats = {}
-
-        if key not in stats:
-            mt = self.duration
-            hits = 1
-        else:
-            mt, hits = stats[key]
-            mt = ((mt * hits) + self.duration) / float(hits + 1)
-            hits += 1
-
-        stats[key] = (mt, hits)
         self.log()
 
     def log(self):



More information about the Zope-Checkins mailing list