diff layer/ScrollableMagRangeCache.cpp @ 1164:f2f43802718b 3.0-integration

More timings and cache hit counts
author Chris Cannam
date Thu, 10 Nov 2016 09:58:28 +0000
parents c53ed1a6fcbd
children a34a2a25907c
line wrap: on
line diff
--- a/layer/ScrollableMagRangeCache.cpp	Tue Nov 08 14:55:53 2016 +0000
+++ b/layer/ScrollableMagRangeCache.cpp	Thu Nov 10 09:58:28 2016 +0000
@@ -14,6 +14,8 @@
 
 #include "ScrollableMagRangeCache.h"
 
+#include "base/HitCount.h"
+
 #include <iostream>
 using namespace std;
 
@@ -23,6 +25,8 @@
 ScrollableMagRangeCache::scrollTo(const LayerGeometryProvider *v,
 				  sv_frame_t newStartFrame)
 {	
+    static HitCount count("ScrollableMagRangeCache: scrolling");
+    
     int dx = (v->getXForFrame(m_startFrame) -
 	      v->getXForFrame(newStartFrame));
 
@@ -33,6 +37,7 @@
 
     if (m_startFrame == newStartFrame) {
 	// haven't moved
+        count.hit();
         return;
     }
     
@@ -40,6 +45,7 @@
 
     if (dx == 0) {
 	// haven't moved visibly (even though start frame may have changed)
+        count.hit();
 	return;
     }
 	
@@ -48,8 +54,11 @@
     if (dx <= -w || dx >= w) {
 	// scrolled entirely off
 	invalidate();
+        count.miss();
 	return;
     }
+
+    count.partial();
 	
     // dx is in range, cache is scrollable