diff data/fileio/WavFileReader.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 6877f4200912
children 200c60de27ca
line wrap: on
line diff
--- a/data/fileio/WavFileReader.cpp	Sat Nov 05 10:41:41 2016 +0000
+++ b/data/fileio/WavFileReader.cpp	Wed Nov 09 18:08:40 2016 +0000
@@ -15,6 +15,8 @@
 
 #include "WavFileReader.h"
 
+#include "base/HitCount.h"
+
 #include <iostream>
 
 #include <QMutexLocker>
@@ -130,6 +132,8 @@
 vector<float>
 WavFileReader::getInterleavedFrames(sv_frame_t start, sv_frame_t count) const
 {
+    static HitCount lastRead("WavFileReader: last read");
+
     if (count == 0) return {};
 
     QMutexLocker locker(&m_mutex);
@@ -152,8 +156,18 @@
     // individual channels, it's quite common for us to be called
     // repeatedly for the same data. So this is worth cacheing.
     if (start == m_lastStart && count == m_lastCount) {
+        lastRead.hit();
         return m_buffer;
     }
+
+    // We don't actually support partial cache reads, but let's use
+    // the term partial to refer to any forward seek and consider a
+    // backward seek to be a miss
+    if (start >= m_lastStart) {
+        lastRead.partial();
+    } else {
+        lastRead.miss();
+    }
     
     if (sf_seek(m_file, start, SEEK_SET) < 0) {
         return {};