summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-08-14 15:19:26 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-08-20 11:31:03 +0200
commita1235446a733164f00a96688784913172456a34e (patch)
tree5c7f0c27f74b804f55cf251f48e88e446a51adc4 /src
parentdcae9a3113d1ce30e330c97dd5a81fec4e272bed (diff)
volume: make the benchmark more meaningfull
MMX is about 6x faster, SSE around 15x on my machine.
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/svolume_mmx.c53
-rw-r--r--src/pulsecore/svolume_sse.c59
2 files changed, 69 insertions, 43 deletions
diff --git a/src/pulsecore/svolume_mmx.c b/src/pulsecore/svolume_mmx.c
index b36fe946..9ad7dea1 100644
--- a/src/pulsecore/svolume_mmx.c
+++ b/src/pulsecore/svolume_mmx.c
@@ -24,8 +24,7 @@
#include <config.h>
#endif
-#include <alloca.h>
-
+#include <pulse/timeval.h>
#include <pulsecore/random.h>
#include <pulsecore/macro.h>
#include <pulsecore/g711.h>
@@ -478,31 +477,45 @@ static void run_test (void) {
int32_t volumes[CHANNELS + PADDING];
int i, j, padding;
pa_do_volume_func_t func;
+ struct timeval start, stop;
- func = pa_get_volume_func (PA_SAMPLE_S16RE);
-
- printf ("checking MMX %d\n", sizeof (samples));
+ func = pa_get_volume_func (PA_SAMPLE_S16NE);
- for (j = 0; j < TIMES; j++) {
- pa_random (samples, sizeof (samples));
- memcpy (samples_ref, samples, sizeof (samples));
- memcpy (samples_orig, samples, sizeof (samples));
+ printf ("checking MMX %zd\n", sizeof (samples));
- for (i = 0; i < CHANNELS; i++)
- volumes[i] = rand() >> 1;
- for (padding = 0; padding < PADDING; padding++, i++)
- volumes[i] = volumes[padding];
+ pa_random (samples, sizeof (samples));
+ memcpy (samples_ref, samples, sizeof (samples));
+ memcpy (samples_orig, samples, sizeof (samples));
- pa_volume_s16re_mmx (samples, volumes, CHANNELS, sizeof (samples));
- func (samples_ref, volumes, CHANNELS, sizeof (samples));
+ for (i = 0; i < CHANNELS; i++)
+ volumes[i] = rand() >> 1;
+ for (padding = 0; padding < PADDING; padding++, i++)
+ volumes[i] = volumes[padding];
- for (i = 0; i < SAMPLES; i++) {
- if (samples[i] != samples_ref[i]) {
- printf ("%d: %04x != %04x (%04x * %04x)\n", i, samples[i], samples_ref[i],
- samples_orig[i], volumes[i % CHANNELS]);
- }
+ func (samples_ref, volumes, CHANNELS, sizeof (samples));
+ pa_volume_s16ne_mmx (samples, volumes, CHANNELS, sizeof (samples));
+ for (i = 0; i < SAMPLES; i++) {
+ if (samples[i] != samples_ref[i]) {
+ printf ("%d: %04x != %04x (%04x * %04x)\n", i, samples[i], samples_ref[i],
+ samples_orig[i], volumes[i % CHANNELS]);
}
}
+
+ pa_gettimeofday(&start);
+ for (j = 0; j < TIMES; j++) {
+ memcpy (samples, samples_orig, sizeof (samples));
+ pa_volume_s16ne_mmx (samples, volumes, CHANNELS, sizeof (samples));
+ }
+ pa_gettimeofday(&stop);
+ pa_log_info("MMX: %llu usec.", (long long unsigned int)pa_timeval_diff (&stop, &start));
+
+ pa_gettimeofday(&start);
+ for (j = 0; j < TIMES; j++) {
+ memcpy (samples_ref, samples_orig, sizeof (samples));
+ func (samples_ref, volumes, CHANNELS, sizeof (samples));
+ }
+ pa_gettimeofday(&stop);
+ pa_log_info("ref: %llu usec.", (long long unsigned int)pa_timeval_diff (&stop, &start));
}
#endif
diff --git a/src/pulsecore/svolume_sse.c b/src/pulsecore/svolume_sse.c
index b60471a7..8138c6c1 100644
--- a/src/pulsecore/svolume_sse.c
+++ b/src/pulsecore/svolume_sse.c
@@ -24,8 +24,7 @@
#include <config.h>
#endif
-#include <alloca.h>
-
+#include <pulse/timeval.h>
#include <pulsecore/random.h>
#include <pulsecore/macro.h>
#include <pulsecore/g711.h>
@@ -459,7 +458,7 @@ pa_volume_s24_32re_sse (uint32_t *samples, int32_t *volumes, unsigned channels,
}
#endif
-#undef RUN_TEST
+#define RUN_TEST
#ifdef RUN_TEST
#define CHANNELS 2
@@ -474,31 +473,45 @@ static void run_test (void) {
int32_t volumes[CHANNELS + PADDING];
int i, j, padding;
pa_do_volume_func_t func;
+ struct timeval start, stop;
- func = pa_get_volume_func (PA_SAMPLE_S16RE);
+ func = pa_get_volume_func (PA_SAMPLE_S16NE);
- printf ("checking SSE %d\n", sizeof (samples));
+ printf ("checking SSE %zd\n", sizeof (samples));
- for (j = 0; j < TIMES; j++) {
- pa_random (samples, sizeof (samples));
- memcpy (samples_ref, samples, sizeof (samples));
- memcpy (samples_orig, samples, sizeof (samples));
-
- for (i = 0; i < CHANNELS; i++)
- volumes[i] = rand() >> 1;
- for (padding = 0; padding < PADDING; padding++, i++)
- volumes[i] = volumes[padding];
-
- pa_volume_s16re_sse (samples, volumes, CHANNELS, SAMPLES * sizeof (int16_t));
- func (samples_ref, volumes, CHANNELS, SAMPLES * sizeof (int16_t));
-
- for (i = 0; i < SAMPLES; i++) {
- if (samples[i] != samples_ref[i]) {
- printf ("%d: %04x != %04x (%04x * %04x)\n", i, samples[i], samples_ref[i],
- samples_orig[i], volumes[i % CHANNELS]);
- }
+ pa_random (samples, sizeof (samples));
+ memcpy (samples_ref, samples, sizeof (samples));
+ memcpy (samples_orig, samples, sizeof (samples));
+
+ for (i = 0; i < CHANNELS; i++)
+ volumes[i] = rand() >> 1;
+ for (padding = 0; padding < PADDING; padding++, i++)
+ volumes[i] = volumes[padding];
+
+ func (samples_ref, volumes, CHANNELS, sizeof (samples));
+ pa_volume_s16ne_sse (samples, volumes, CHANNELS, sizeof (samples));
+ for (i = 0; i < SAMPLES; i++) {
+ if (samples[i] != samples_ref[i]) {
+ printf ("%d: %04x != %04x (%04x * %04x)\n", i, samples[i], samples_ref[i],
+ samples_orig[i], volumes[i % CHANNELS]);
}
}
+
+ pa_gettimeofday(&start);
+ for (j = 0; j < TIMES; j++) {
+ memcpy (samples, samples_orig, sizeof (samples));
+ pa_volume_s16ne_sse (samples, volumes, CHANNELS, sizeof (samples));
+ }
+ pa_gettimeofday(&stop);
+ pa_log_info("SSE: %llu usec.", (long long unsigned int)pa_timeval_diff (&stop, &start));
+
+ pa_gettimeofday(&start);
+ for (j = 0; j < TIMES; j++) {
+ memcpy (samples_ref, samples_orig, sizeof (samples));
+ func (samples_ref, volumes, CHANNELS, sizeof (samples));
+ }
+ pa_gettimeofday(&stop);
+ pa_log_info("ref: %llu usec.", (long long unsigned int)pa_timeval_diff (&stop, &start));
}
#endif