comparison 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
comparison
equal deleted inserted replaced
1255:ca9032dd2811 1256:d8d6d01505ed
16 #include "FFTModel.h" 16 #include "FFTModel.h"
17 #include "DenseTimeValueModel.h" 17 #include "DenseTimeValueModel.h"
18 18
19 #include "base/Profiler.h" 19 #include "base/Profiler.h"
20 #include "base/Pitch.h" 20 #include "base/Pitch.h"
21 #include "base/HitCount.h"
21 22
22 #include <algorithm> 23 #include <algorithm>
23 24
24 #include <cassert> 25 #include <cassert>
25 #include <deque> 26 #include <deque>
26 27
27 using namespace std; 28 using namespace std;
29
30 static HitCount inSmallCache("FFTModel: Small FFT cache");
31 static HitCount inSourceCache("FFTModel: Source data cache");
28 32
29 FFTModel::FFTModel(const DenseTimeValueModel *model, 33 FFTModel::FFTModel(const DenseTimeValueModel *model,
30 int channel, 34 int channel,
31 WindowType windowType, 35 WindowType windowType,
32 int windowSize, 36 int windowSize,
213 // cerr << "getSourceData(" << range.first << "," << range.second 217 // cerr << "getSourceData(" << range.first << "," << range.second
214 // << "): saved range is (" << m_savedData.range.first 218 // << "): saved range is (" << m_savedData.range.first
215 // << "," << m_savedData.range.second << ")" << endl; 219 // << "," << m_savedData.range.second << ")" << endl;
216 220
217 if (m_savedData.range == range) { 221 if (m_savedData.range == range) {
222 inSourceCache.hit();
218 return m_savedData.data; 223 return m_savedData.data;
219 } 224 }
220 225
221 if (range.first < m_savedData.range.second && 226 if (range.first < m_savedData.range.second &&
222 range.first >= m_savedData.range.first && 227 range.first >= m_savedData.range.first &&
223 range.second > m_savedData.range.second) { 228 range.second > m_savedData.range.second) {
224 229
230 inSourceCache.partial();
231
225 sv_frame_t discard = range.first - m_savedData.range.first; 232 sv_frame_t discard = range.first - m_savedData.range.first;
226 233
227 vector<float> acc(m_savedData.data.begin() + discard, 234 vector<float> acc(m_savedData.data.begin() + discard,
228 m_savedData.data.end()); 235 m_savedData.data.end());
229 236
235 m_savedData = { range, acc }; 242 m_savedData = { range, acc };
236 return acc; 243 return acc;
237 244
238 } else { 245 } else {
239 246
247 inSourceCache.miss();
248
240 auto data = getSourceDataUncached(range); 249 auto data = getSourceDataUncached(range);
241 m_savedData = { range, data }; 250 m_savedData = { range, data };
242 return data; 251 return data;
243 } 252 }
244 } 253 }
282 vector<complex<float>> 291 vector<complex<float>>
283 FFTModel::getFFTColumn(int n) const 292 FFTModel::getFFTColumn(int n) const
284 { 293 {
285 for (auto &incache : m_cached) { 294 for (auto &incache : m_cached) {
286 if (incache.n == n) { 295 if (incache.n == n) {
296 inSmallCache.hit();
287 return incache.col; 297 return incache.col;
288 } 298 }
289 } 299 }
300 inSmallCache.miss();
290 301
291 auto samples = getSourceSamples(n); 302 auto samples = getSourceSamples(n);
292 m_windower.cut(samples.data()); 303 m_windower.cut(samples.data());
293 auto col = m_fft.process(samples); 304 auto col = m_fft.process(samples);
294 305