r4116 - in trunk/bse: . tests



Author: stw
Date: 2006-12-02 18:02:36 -0500 (Sat, 02 Dec 2006)
New Revision: 4116

Modified:
   trunk/bse/ChangeLog
   trunk/bse/bsedatahandle-fir.cc
   trunk/bse/tests/Makefile.am
   trunk/bse/tests/firhandle.cc
Log:
Sat Dec  2 23:55:44 2006  Stefan Westerfeld  <stefan space twc de>

	* tests/Makefile.am:
	* tests/firhandle.cc: Added a test for the highpass performance.
	
	* bsedatahandle-fir.cc: Optimized performance of the highpass handle.
	It is plain FPU code (not SSE), though.


Modified: trunk/bse/ChangeLog
===================================================================
--- trunk/bse/ChangeLog	2006-12-02 21:12:57 UTC (rev 4115)
+++ trunk/bse/ChangeLog	2006-12-02 23:02:36 UTC (rev 4116)
@@ -1,3 +1,11 @@
+Sat Dec  2 23:55:44 2006  Stefan Westerfeld  <stefan space twc de>
+
+	* tests/Makefile.am:
+	* tests/firhandle.cc: Added a test for the highpass performance.
+	
+	* bsedatahandle-fir.cc: Optimized performance of the highpass handle.
+	It is plain FPU code (not SSE), though.
+
 Sat Dec  2 22:03:57 2006  Stefan Westerfeld  <stefan space twc de>
 
 	* tests/firhandle.cc: Added a highpass test for multichannel signals.

Modified: trunk/bse/bsedatahandle-fir.cc
===================================================================
--- trunk/bse/bsedatahandle-fir.cc	2006-12-02 21:12:57 UTC (rev 4115)
+++ trunk/bse/bsedatahandle-fir.cc	2006-12-02 23:02:36 UTC (rev 4116)
@@ -19,6 +19,7 @@
 #include "gsldatahandle.h"
 #include "gsldatautils.h"
 #include "gslfilter.h"
+#include "bseblockutils.hh"
 #include <complex>
 #include <vector>
 #include <string.h>
@@ -111,24 +112,24 @@
   }
 
   void
-  fir_apply (const gfloat *src,
-	     const guint   n_samples,
-	     gfloat       *dest)
+  fir_apply (guint        voffset,
+	     const guint  n_samples,
+	     gfloat      *dest) const
   {
-    /* tiny FIR evaluation: not optimized for speed */
     const guint channels = m_dhandle.setup.n_channels;
     const guint iorder = m_a.size();
+    voffset += m_history - (iorder / 2) * channels;
+
     for (guint i = 0; i < n_samples; i++)
       {
 	gdouble accu = 0;
-	GslLong p = i;
-	p -= (iorder / 2) * channels; 
-	for (guint j = 0; j <= iorder; j++)
+	vector<float>::const_iterator si = m_input_data.begin() + voffset + i;
+	for (vector<double>::const_iterator ai = m_a.begin(); ai != m_a.end(); ai++)
 	  {
-	    accu += m_a[j] * src[p];
-	    p += channels;
+	    accu += *ai * *si;
+	    si += channels;
 	  }
-	dest[i] = accu;
+	*dest++ = accu;
       }
   }
 
@@ -143,7 +144,7 @@
     if (m_input_voffset == voffset - m_block_size)
       {
 	int64 overlap_values = 2 * m_history;
-	copy (m_input_data.end() - overlap_values, m_input_data.end(), m_input_data.begin());
+	Block::copy (overlap_values, &m_input_data[0], &m_input_data[m_input_data.size() - overlap_values]);
 	i += overlap_values;
       }
 
@@ -190,13 +191,10 @@
       }
 
     g_assert (ivoffset == m_input_voffset);
-    vector<float> dest_data (m_input_data.size());
-    fir_apply (&m_input_data[m_history], m_block_size, &dest_data[m_history]);
     
     voffset -= ivoffset;
     n_values = min (n_values, m_block_size - voffset);
-    voffset += m_history;
-    std::copy (&dest_data[voffset], &dest_data[voffset + n_values], values);
+    fir_apply (voffset, n_values, values);
     return n_values;
   }
 

Modified: trunk/bse/tests/Makefile.am
===================================================================
--- trunk/bse/tests/Makefile.am	2006-12-02 21:12:57 UTC (rev 4115)
+++ trunk/bse/tests/Makefile.am	2006-12-02 23:02:36 UTC (rev 4116)
@@ -51,5 +51,6 @@
 resamplehandle_LDADD   = $(progs_ldadd)
 
 TESTS                 += firhandle
+PERFTESTS             += firhandle
 firhandle_SOURCES      = firhandle.cc
 firhandle_LDADD        = $(progs_ldadd)

Modified: trunk/bse/tests/firhandle.cc
===================================================================
--- trunk/bse/tests/firhandle.cc	2006-12-02 21:12:57 UTC (rev 4115)
+++ trunk/bse/tests/firhandle.cc	2006-12-02 23:02:36 UTC (rev 4116)
@@ -31,7 +31,25 @@
 using std::min;
 using std::max;
 
-double
+static void
+read_through (GslDataHandle *handle)
+{
+  int64 n_values = gsl_data_handle_n_values (handle);
+  int64 offset = 0;
+
+  while (offset < n_values)
+    {
+      // we don't use 1024 here, because we know that it is the FIR handle internal buffer size
+      gfloat values[700];
+      int64 values_read = gsl_data_handle_read (handle, offset, 700, values);
+      g_assert (values_read > 0);
+      offset += values_read;
+    }
+
+  g_assert (offset == n_values);
+}
+
+static double
 phase_diff (double p1,
             double p2)
 {
@@ -146,6 +164,30 @@
   TASSERT (pass2_min_db > -0.004 && pass2_max_db < 0.002);
   TASSERT (phase_diff_max < 0.0002);
   TDONE();
+
+  /* test speed */
+  double samples_per_second = 0;
+  if (sfi_init_settings().test_perf)
+    {
+      const guint RUNS = 10;
+      GTimer *timer = g_timer_new();
+      const guint dups = TEST_CALIBRATION (50.0, read_through (fir_handle_sin));
+      
+      double m = 9e300;
+      for (guint i = 0; i < RUNS; i++)
+        {
+          g_timer_start (timer);
+          for (guint j = 0; j < dups; j++)
+            read_through (fir_handle_sin);
+          g_timer_stop (timer);
+          double e = g_timer_elapsed (timer, NULL);
+          if (e < m)
+            m = e;
+        }
+      samples_per_second = sweep_sin.size() / (m / dups);
+      treport_maximized ("Highpass O64 mono", samples_per_second, TUNIT (SAMPLE, SECOND));
+      treport_maximized ("CPU Highpass mono", samples_per_second / 44100.0, TUNIT_STREAM);
+    }
 }
 
 double




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]