r4000 - in trunk/bse: . tests
- From: timj svn gnome org
- To: svn-commits-list gnome org
- Subject: r4000 - in trunk/bse: . tests
- Date: Sat, 21 Oct 2006 13:06:04 -0400 (EDT)
Author: timj
Date: 2006-10-21 13:05:37 -0400 (Sat, 21 Oct 2006)
New Revision: 4000
Modified:
trunk/bse/ChangeLog
trunk/bse/tests/Makefile.am
trunk/bse/tests/resamplehandle.cc
trunk/bse/tests/subnormals.cc
Log:
Sat Oct 21 18:58:35 2006 Tim Janik <timj gtk org>
* tests/resamplehandle.cc: reworked to split performance tests from
ordinary tests. speed up ordinary tests if --test-slow was not
specified. fixed test program to use TASSERT() instead of silent exit
or return_if_fail on errors.
* tests/subnormals.cc: refactored a bit, split up performance tests.
Modified: trunk/bse/ChangeLog
===================================================================
--- trunk/bse/ChangeLog 2006-10-21 17:03:31 UTC (rev 3999)
+++ trunk/bse/ChangeLog 2006-10-21 17:05:37 UTC (rev 4000)
@@ -1,3 +1,12 @@
+Sat Oct 21 18:58:35 2006 Tim Janik <timj gtk org>
+
+ * tests/resamplehandle.cc: reworked to split performance tests from
+ ordinary tests. speed up ordinary tests if --test-slow was not
+ specified. fixed test program to use TASSERT() instead of silent exit
+ or return_if_fail on errors.
+
+ * tests/subnormals.cc: refactored a bit, split up performance tests.
+
Fri Oct 20 23:03:57 2006 Stefan Westerfeld <stefan space twc de>
* gslfilter.c (gsl_filter_sine_scan): Fixed a small bug in block
Modified: trunk/bse/tests/Makefile.am
===================================================================
--- trunk/bse/tests/Makefile.am 2006-10-21 17:03:31 UTC (rev 3999)
+++ trunk/bse/tests/Makefile.am 2006-10-21 17:05:37 UTC (rev 4000)
@@ -24,6 +24,7 @@
testcxx_LDADD = $(progs_ldadd)
TESTS += subnormals
+PERFTESTS += subnormals
subnormals_SOURCES = subnormals.cc subnormals-aux.cc
subnormals_LDADD = $(progs_ldadd)
subnormals_CXXFLAGS = $(AM_CXXFLAGS) -ffast-math
@@ -37,5 +38,7 @@
blocktests_LDADD = $(progs_ldadd)
TESTS += resamplehandle
+SLOWTESTS += resamplehandle
+PERFTESTS += resamplehandle
resamplehandle_SOURCES = resamplehandle.cc
resamplehandle_LDADD = $(progs_ldadd)
Modified: trunk/bse/tests/resamplehandle.cc
===================================================================
--- trunk/bse/tests/resamplehandle.cc 2006-10-21 17:03:31 UTC (rev 3999)
+++ trunk/bse/tests/resamplehandle.cc 2006-10-21 17:05:37 UTC (rev 4000)
@@ -47,32 +47,39 @@
}
static double
-check (const vector<float> &input,
+check (const char *up_down,
+ const char *channels,
+ uint bits,
+ const char *cpu_type,
+ const vector<float> &input,
const vector<double> &expected,
int n_channels,
BseResampler2Mode resampler_mode,
int precision_bits,
double max_db)
{
- g_return_val_if_fail (input.size() % n_channels == 0, 0);
+ char *samplestr = g_strdup_printf ("%s-ResampleHandle-%s%02d%s", cpu_type, up_down, bits, channels);
+ char *streamstr = g_strdup_printf ("CPU Resampling %s-%s%02d%s", cpu_type, up_down, bits, channels);
+ TSTART ("%s", samplestr);
+
+ TASSERT (input.size() % n_channels == 0);
GslDataHandle *ihandle = gsl_data_handle_new_mem (n_channels, 32, 44100, 440, input.size(), &input[0], NULL);
GslDataHandle *rhandle;
if (resampler_mode == BSE_RESAMPLER2_MODE_UPSAMPLE)
{
- g_return_val_if_fail (input.size() * 2 == expected.size(), 0);
+ TASSERT (input.size() * 2 == expected.size());
rhandle = bse_data_handle_new_upsample2 (ihandle, precision_bits);
}
else
{
- g_return_val_if_fail (input.size() == expected.size() * 2, 0);
+ TASSERT (input.size() == expected.size() * 2);
rhandle = bse_data_handle_new_downsample2 (ihandle, precision_bits);
}
gsl_data_handle_unref (ihandle);
BseErrorType error = gsl_data_handle_open (rhandle);
- if (error)
- exit (1);
+ TASSERT (error == 0);
double worst_diff, worst_diff_db;
@@ -93,7 +100,8 @@
/* test seeking */
worst_diff = 0.0;
- for (int i = 0; i < 1000; i++)
+ const uint count = sfi_init_settings().test_slow ? 3000 : 100;
+ for (uint j = 0; j < count; j++)
{
int64 start = rand() % rhandle->setup.n_values;
int64 len = rand() % 1024;
@@ -109,30 +117,41 @@
TPRINT ("seek worst_diff = %f (%f dB)\n", worst_diff, worst_diff_db);
TASSERT (worst_diff_db < max_db);
+ TDONE();
+
/* test speed */
- const guint RUNS = 10;
- GTimer *timer = g_timer_new();
- const guint dups = TEST_CALIBRATION (50.0, read_through (rhandle));
-
- double m = 9e300;
- for (guint i = 0; i < RUNS; i++)
+ double samples_per_second = 0;
+ if (sfi_init_settings().test_perf)
{
- g_timer_start (timer);
- for (guint j = 0; j < dups; j++)
- read_through (rhandle);
- g_timer_stop (timer);
- double e = g_timer_elapsed (timer, NULL);
- if (e < m)
- m = e;
+ const guint RUNS = 10;
+ GTimer *timer = g_timer_new();
+ const guint dups = TEST_CALIBRATION (50.0, read_through (rhandle));
+
+ double m = 9e300;
+ for (guint i = 0; i < RUNS; i++)
+ {
+ g_timer_start (timer);
+ for (guint j = 0; j < dups; j++)
+ read_through (rhandle);
+ g_timer_stop (timer);
+ double e = g_timer_elapsed (timer, NULL);
+ if (e < m)
+ m = e;
+ }
+ samples_per_second = input.size() / (m / dups);
+ treport_maximized (samplestr, samples_per_second, TUNIT (SAMPLE, SECOND));
+ treport_maximized (streamstr, samples_per_second / 44100.0, TUNIT_STREAM);
+ //TPRINT (" samples / second = %f\n", samples_per_second);
+ //TPRINT (" which means the resampler can process %.2f 44100 Hz streams simultaneusly\n", samples_per_second / 44100.0);
+ //TPRINT (" or one 44100 Hz stream takes %f %% CPU usage\n", 100.0 / (samples_per_second / 44100.0));
}
- double samples_per_second = input.size() / (m / dups);
- TPRINT (" samples / second = %f\n", samples_per_second);
- TPRINT (" which means the resampler can process %.2f 44100 Hz streams simultaneusly\n", samples_per_second / 44100.0);
- TPRINT (" or one 44100 Hz stream takes %f %% CPU usage\n", 100.0 / (samples_per_second / 44100.0));
gsl_data_handle_close (rhandle);
gsl_data_handle_unref (rhandle);
+ g_free (samplestr);
+ g_free (streamstr);
+
return samples_per_second / 44100.0;
}
@@ -185,56 +204,48 @@
vector<double> expected;
// mono upsampling test
- {
- generate_test_signal (input, LEN, 44100, 440);
- generate_test_signal (expected, LEN * 2, 88200, 440);
-
- TSTART ("ResampleHandle %dbits mono upsampling (%s)", params[p].bits, run_type);
- double streams = check (input, expected, 1, BSE_RESAMPLER2_MODE_UPSAMPLE,
- params[p].bits, params[p].mono_upsample_db);
- TDONE();
-
- g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
- }
-
+ if (!sfi_init_settings().test_quick)
+ {
+ generate_test_signal (input, LEN, 44100, 440);
+ generate_test_signal (expected, LEN * 2, 88200, 440);
+ check ("Up", "M", params[p].bits, run_type,
+ input, expected, 1, BSE_RESAMPLER2_MODE_UPSAMPLE,
+ params[p].bits, params[p].mono_upsample_db);
+ // g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
+ }
+
// stereo upsampling test
- {
- generate_test_signal (input, LEN, 44100, 440, 1000);
- generate_test_signal (expected, LEN * 2, 88200, 440, 1000);
-
- TSTART ("ResampleHandle %dbits stereo upsampling (%s)", params[p].bits, run_type);
- double streams = check (input, expected, 2, BSE_RESAMPLER2_MODE_UPSAMPLE,
- params[p].bits, params[p].stereo_upsample_db);
- TDONE();
-
- g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
- }
-
+ if (1)
+ {
+ generate_test_signal (input, LEN, 44100, 440, 1000);
+ generate_test_signal (expected, LEN * 2, 88200, 440, 1000);
+ check ("Up", "S", params[p].bits, run_type,
+ input, expected, 2, BSE_RESAMPLER2_MODE_UPSAMPLE,
+ params[p].bits, params[p].stereo_upsample_db);
+ // g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
+ }
+
// mono downsampling test
- {
- generate_test_signal (input, LEN, 44100, 440);
- generate_test_signal (expected, LEN / 2, 22050, 440);
-
- TSTART ("ResampleHandle %dbits mono downsampling (%s)", params[p].bits, run_type);
- double streams = check (input, expected, 1, BSE_RESAMPLER2_MODE_DOWNSAMPLE,
- params[p].bits, params[p].mono_downsample_db);
- TDONE();
-
- g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
- }
-
+ if (!sfi_init_settings().test_quick)
+ {
+ generate_test_signal (input, LEN, 44100, 440);
+ generate_test_signal (expected, LEN / 2, 22050, 440);
+ check ("Dn", "M", params[p].bits, run_type,
+ input, expected, 1, BSE_RESAMPLER2_MODE_DOWNSAMPLE,
+ params[p].bits, params[p].mono_downsample_db);
+ // g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
+ }
+
// stereo downsampling test
- {
- generate_test_signal (input, LEN, 44100, 440, 1000);
- generate_test_signal (expected, LEN / 2, 22050, 440, 1000);
-
- TSTART ("ResampleHandle %dbits stereo downsampling (%s)", params[p].bits, run_type);
- double streams = check (input, expected, 2, BSE_RESAMPLER2_MODE_DOWNSAMPLE,
- params[p].bits, params[p].stereo_downsample_db);
- TDONE();
-
- g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
- }
+ if (1)
+ {
+ generate_test_signal (input, LEN, 44100, 440, 1000);
+ generate_test_signal (expected, LEN / 2, 22050, 440, 1000);
+ check ("Dn", "S", params[p].bits, run_type,
+ input, expected, 2, BSE_RESAMPLER2_MODE_DOWNSAMPLE,
+ params[p].bits, params[p].stereo_downsample_db);
+ // g_printerr (" ===> speed is equivalent to %.2f simultaneous 44100 Hz streams\n", streams);
+ }
}
}
Modified: trunk/bse/tests/subnormals.cc
===================================================================
--- trunk/bse/tests/subnormals.cc 2006-10-21 17:03:31 UTC (rev 3999)
+++ trunk/bse/tests/subnormals.cc 2006-10-21 17:05:37 UTC (rev 4000)
@@ -89,25 +89,13 @@
TDONE();
}
-int
-main (int argc,
- char *argv[])
+static void
+benchmark_subnormal_eliminations ()
{
- bse_init_test (&argc, &argv, NULL);
+ const float max_sub = BSE_FLOAT_MAX_SUBNORMAL;
- test_correct_subnormal_elimination<test2f> ("zap");
- test_correct_subnormal_elimination<test3f> ("inlined-cond");
- test_correct_subnormal_elimination<test4f> ("if-cond");
- test_correct_subnormal_elimination<test5f> ("arithmetic");
+ TSTART ("Subnormal Cancellation Benchmark");
- test_correct_subnormal_elimination<test2d> ("zap-double");
- test_correct_subnormal_elimination<test3d> ("inlined-cond-double");
- test_correct_subnormal_elimination<test4d> ("if-cond-double");
- test_correct_subnormal_elimination<test5d> ("arithmetic-double");
-
- g_print ("benchmarking...\n");
- const float max_sub = BSE_FLOAT_MAX_SUBNORMAL;
-
float n = 10 * 1000000;
float sum;
GTimer *timer = g_timer_new();
@@ -117,6 +105,8 @@
const int blen = 4096;
volatile float buffer[blen];
+ TOK();
+
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
g_timer_start (timer);
@@ -130,7 +120,8 @@
volatile_accu += sum;
g_timer_stop (timer);
float test1_time = g_timer_elapsed (timer, NULL);
-
+ TOK();
+
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
g_timer_start (timer);
@@ -144,6 +135,7 @@
volatile_accu += sum;
g_timer_stop (timer);
float test2_time = g_timer_elapsed (timer, NULL);
+ TOK();
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
@@ -158,6 +150,7 @@
volatile_accu += sum;
g_timer_stop (timer);
float test3_time = g_timer_elapsed (timer, NULL);
+ TOK();
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
@@ -172,6 +165,7 @@
volatile_accu += sum;
g_timer_stop (timer);
float test4_time = g_timer_elapsed (timer, NULL);
+ TOK();
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
@@ -186,6 +180,7 @@
volatile_accu += sum;
g_timer_stop (timer);
float test5_time = g_timer_elapsed (timer, NULL);
+ TOK();
sum = j = 0;
memset ((void*) buffer, 0, sizeof (buffer));
@@ -202,10 +197,39 @@
}
volatile_accu += sum;
g_timer_stop (timer);
- float test_bse_time = g_timer_elapsed (timer, NULL);
+ float test6_time = g_timer_elapsed (timer, NULL);
+ TOK();
+ TDONE();
- g_print ("subnormal cancellation times: keep=%fs zap=%fs inlined-cond=%fs if-cond=%fs arithmetic=%f bse=%f\n",
- test1_time, test2_time, test3_time, test4_time, test5_time, test_bse_time);
+ if (0)
+ g_print ("subnormal cancellation times: keep=%fs zap=%fs inlined-cond=%fs if-cond=%fs arithmetic=%f bse=%f\n",
+ test1_time, test2_time, test3_time, test4_time, test5_time, test6_time);
+ treport_minimized ("Subnormals-keep", test1_time, TUNIT_SECOND);
+ treport_minimized ("Subnormals-bse-zap", test2_time, TUNIT_SECOND);
+ treport_minimized ("Subnormals-inlined-cond", test3_time, TUNIT_SECOND);
+ treport_minimized ("Subnormals-if-cond", test4_time, TUNIT_SECOND);
+ treport_minimized ("Subnormals-arithmetic", test5_time, TUNIT_SECOND);
+ treport_minimized ("Subnormals-bse-flush", test6_time, TUNIT_SECOND);
+}
+int
+main (int argc,
+ char *argv[])
+{
+ bse_init_test (&argc, &argv, NULL);
+
+ test_correct_subnormal_elimination<test2f> ("zap");
+ test_correct_subnormal_elimination<test3f> ("inlined-cond");
+ test_correct_subnormal_elimination<test4f> ("if-cond");
+ test_correct_subnormal_elimination<test5f> ("arithmetic");
+
+ test_correct_subnormal_elimination<test2d> ("zap-double");
+ test_correct_subnormal_elimination<test3d> ("inlined-cond-double");
+ test_correct_subnormal_elimination<test4d> ("if-cond-double");
+ test_correct_subnormal_elimination<test5d> ("arithmetic-double");
+
+ if (sfi_init_settings().test_perf)
+ benchmark_subnormal_eliminations();
+
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]