changeset 1457:0925b37a3ed1

Some messing around with profiling
author Chris Cannam
date Tue, 24 Apr 2018 14:13:51 +0100
parents 904e031c9c76
children 0fb5d4e6edeb
files data/model/FFTModel.cpp data/model/ReadOnlyWaveFileModel.cpp
diffstat 2 files changed, 34 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/FFTModel.cpp	Tue Apr 24 10:01:34 2018 +0100
+++ b/data/model/FFTModel.cpp	Tue Apr 24 14:13:51 2018 +0100
@@ -241,14 +241,20 @@
         
         sv_frame_t discard = range.first - m_savedData.range.first;
 
-        fvec acc(m_savedData.data.begin() + discard, m_savedData.data.end());
+        fvec data;
+        data.reserve(range.second - range.first);
 
-        fvec rest = getSourceDataUncached({ m_savedData.range.second, range.second });
+        data.insert(data.end(),
+                    m_savedData.data.begin() + discard,
+                    m_savedData.data.end());
 
-        acc.insert(acc.end(), rest.begin(), rest.end());
+        fvec rest = getSourceDataUncached
+            ({ m_savedData.range.second, range.second });
+
+        data.insert(data.end(), rest.begin(), rest.end());
         
-        m_savedData = { range, acc };
-        return acc;
+        m_savedData = { range, data };
+        return data;
 
     } else {
 
@@ -263,6 +269,8 @@
 FFTModel::fvec
 FFTModel::getSourceDataUncached(pair<sv_frame_t, sv_frame_t> range) const
 {
+    Profiler profiler("FFTModel::getSourceDataUncached");
+    
     decltype(range.first) pfx = 0;
     if (range.first < 0) {
         pfx = -range.first;
--- a/data/model/ReadOnlyWaveFileModel.cpp	Tue Apr 24 10:01:34 2018 +0100
+++ b/data/model/ReadOnlyWaveFileModel.cpp	Tue Apr 24 14:13:51 2018 +0100
@@ -207,11 +207,17 @@
 }
     
 floatvec_t
-ReadOnlyWaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count) const
+ReadOnlyWaveFileModel::getData(int channel,
+                               sv_frame_t start,
+                               sv_frame_t count)
+    const
 {
-    // Read directly from the file.  This is used for e.g. audio
-    // playback or input to transforms.
+    // Read a single channel (if channel >= 0) or a mixdown of all
+    // channels (if channel == -1) directly from the file.  This is
+    // used for e.g. audio playback or input to transforms.
 
+    Profiler profiler("ReadOnlyWaveFileModel::getData");
+    
 #ifdef DEBUG_WAVE_FILE_MODEL
     cout << "ReadOnlyWaveFileModel::getData[" << this << "]: " << channel << ", " << start << ", " << count << endl;
 #endif
@@ -268,8 +274,10 @@
 ReadOnlyWaveFileModel::getMultiChannelData(int fromchannel, int tochannel,
                                            sv_frame_t start, sv_frame_t count) const
 {
-    // Read directly from the file.  This is used for e.g. audio
-    // playback or input to transforms.
+    // Read a set of channels directly from the file.  This is used
+    // for e.g. audio playback or input to transforms.
+
+    Profiler profiler("ReadOnlyWaveFileModel::getMultiChannelData");
 
 #ifdef DEBUG_WAVE_FILE_MODEL
     cout << "ReadOnlyWaveFileModel::getData[" << this << "]: " << fromchannel << "," << tochannel << ", " << start << ", " << count << endl;
@@ -278,16 +286,18 @@
     int channels = getChannelCount();
 
     if (fromchannel > tochannel) {
-        SVCERR << "ERROR: ReadOnlyWaveFileModel::getData: fromchannel ("
-                  << fromchannel << ") > tochannel (" << tochannel << ")"
-                  << endl;
+        SVCERR << "ERROR: ReadOnlyWaveFileModel::getMultiChannelData: "
+               << "fromchannel (" << fromchannel
+               << ") > tochannel (" << tochannel << ")"
+               << endl;
         return {};
     }
 
     if (tochannel >= channels) {
-        SVCERR << "ERROR: ReadOnlyWaveFileModel::getData: tochannel ("
-                  << tochannel << ") >= channel count (" << channels << ")"
-                  << endl;
+        SVCERR << "ERROR: ReadOnlyWaveFileModel::getMultiChannelData: "
+               << "tochannel (" << tochannel
+               << ") >= channel count (" << channels << ")"
+               << endl;
         return {};
     }