diff data/model/FFTModel.cpp @ 1256:d8d6d01505ed 3.0-integration

Print out cache hit/miss counts
author Chris Cannam
date Wed, 09 Nov 2016 18:08:40 +0000
parents 6b847a59d908
children 5236543343c3
line wrap: on
line diff
--- a/data/model/FFTModel.cpp	Sat Nov 05 10:41:41 2016 +0000
+++ b/data/model/FFTModel.cpp	Wed Nov 09 18:08:40 2016 +0000
@@ -18,6 +18,7 @@
 
 #include "base/Profiler.h"
 #include "base/Pitch.h"
+#include "base/HitCount.h"
 
 #include <algorithm>
 
@@ -26,6 +27,9 @@
 
 using namespace std;
 
+static HitCount inSmallCache("FFTModel: Small FFT cache");
+static HitCount inSourceCache("FFTModel: Source data cache");
+
 FFTModel::FFTModel(const DenseTimeValueModel *model,
                    int channel,
                    WindowType windowType,
@@ -215,6 +219,7 @@
 //         << "," << m_savedData.range.second << ")" << endl;
 
     if (m_savedData.range == range) {
+        inSourceCache.hit();
         return m_savedData.data;
     }
 
@@ -222,6 +227,8 @@
         range.first >= m_savedData.range.first &&
         range.second > m_savedData.range.second) {
 
+        inSourceCache.partial();
+        
         sv_frame_t discard = range.first - m_savedData.range.first;
 
         vector<float> acc(m_savedData.data.begin() + discard,
@@ -237,6 +244,8 @@
 
     } else {
 
+        inSourceCache.miss();
+        
         auto data = getSourceDataUncached(range);
         m_savedData = { range, data };
         return data;
@@ -284,9 +293,11 @@
 {
     for (auto &incache : m_cached) {
         if (incache.n == n) {
+            inSmallCache.hit();
             return incache.col;
         }
     }
+    inSmallCache.miss();
     
     auto samples = getSourceSamples(n);
     m_windower.cut(samples.data());