ref: 0bbb338f2f518e3dad30329411978b98856a3162
parent: c841b0aaf00d70c8d4b7c5400f15d0152cf53c7d
author: Erik de Castro Lopo <erikd@miles>
date: Wed Jun 9 06:27:10 EDT 2004
Pull in benchmark program from --benchmark branch. Patches applied: * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--base-0 tag of erikd@miles--2004/SecretRabbitCode--mdev--0.1.0--patch-41 * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-1 Move calc_output above sinc_process so that it can be inlined. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-2 Merge changes from mainline. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-3 Add benchmark program to tests/ dir. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-4 Updates benchmark to check SNR. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-5 Add text to store results of benchmarking. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-6 Single loop plus two if implementation of calc_output. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-7 Double length of data array in benchmark. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-8 Add old calc_output with #if around it. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-9 Increase length of input in benchmark.c. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-10 Merge from --mdev branch. * erikd@miles--2004/SecretRabbitCode--benchmark--0.1.0--patch-11 Add benchmark results, merge changes from --mdev branch.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-06-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/benchmark.c
+ Added benchmark program.
+
2004-05-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/callback_test.c
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,7 @@
noinst_PROGRAMS = misc_test termination_test simple_test callback_test \
reset_test multi_channel_test snr_bw_test \
- float_short_test src-evaluate
-
+ float_short_test src-evaluate benchmark
+
SAMPLRATEDIR =../src
INCLUDES = -I$(srcdir)/$(SAMPLRATEDIR)
noinst_HEADERS = calc_snr.h util.h
@@ -40,6 +40,10 @@
src_evaluate_SOURCES = src-evaluate.c calc_snr.c util.c
src_evaluate_CFLAGS = @SNDFILE_CFLAGS@ @FFTW3_CFLAGS@
src_evaluate_LDADD = $(SNDFILE_LIBS) $(FFTW3_LIBS)
+
+benchmark_CFLAGS = $(AM_CFLAGS)
+benchmark_SOURCES = benchmark.c util.c calc_snr.c
+benchmark_LDADD = $(SAMPLRATEDIR)/libsamplerate.la $(FFTW3_LIBS)
#===============================================================================
--- /dev/null
+++ b/tests/benchmark.c
@@ -1,0 +1,75 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <time.h>
+
+#include <samplerate.h>
+
+#include "util.h"
+#include "calc_snr.h"
+
+#define BUFFER_LEN (1<<23)
+#define SNR_LEN (1<<16)
+
+#define ARRAY_LEN(x) ((int)(sizeof (x)) / (sizeof ((x) [0])))
+
+static float input [BUFFER_LEN];
+static float output [BUFFER_LEN];
+
+int
+main (void)
+{ SRC_DATA src_data ;
+ clock_t start_time, clock_time ;
+ double freq ;
+ int error ;
+
+ memset (input, 0, sizeof (input)) ;
+ freq = 0.01 ;
+ gen_windowed_sines (input, SNR_LEN, &freq, 1) ;
+
+
+ src_data.data_in = input ;
+ src_data.input_frames = ARRAY_LEN (input) ;
+
+ src_data.data_out = output ;
+ src_data.output_frames = ARRAY_LEN (output) ;
+
+ src_data.src_ratio = 0.99 ;
+
+ start_time = clock () ;
+
+ if ((error = src_simple (&src_data, SRC_SINC_BEST_QUALITY, 1)) != 0)
+ { puts (src_strerror (error)) ;
+ exit (1) ;
+ } ;
+
+ clock_time = clock () - start_time ;
+
+ if (src_data.input_frames_used != ARRAY_LEN (input))
+ { printf ("\n\nLine %d : input frames used %ld should be %d\n", __LINE__, src_data.input_frames_used, ARRAY_LEN (input)) ;
+ exit (1) ;
+ } ;
+
+ if (fabs (src_data.src_ratio * src_data.input_frames_used - src_data.output_frames_gen) > 2)
+ { printf ("\n\nLine %d : input / output length mismatch.\n\n", __LINE__) ;
+ printf (" input len : %d\n", ARRAY_LEN (input)) ;
+ printf (" output len : %ld (should be %g +/- 2)\n\n", src_data.output_frames_gen,
+ floor (0.5 + src_data.src_ratio * src_data.input_frames_used)) ;
+ exit (1) ;
+ } ;
+
+ printf ("Time : %5.2f secs.\n", (1.0 * clock_time) / CLOCKS_PER_SEC) ;
+ printf ("Throughput : %d samples/sec\n", (int) floor (src_data.output_frames_gen / ((1.0 * clock_time) / CLOCKS_PER_SEC))) ;
+ printf ("SNR : %6.2f dB\n", calculate_snr (output, SNR_LEN)) ;
+
+ return 0 ;
+} /* main */
+
+/*
+** Do not edit or modify anything in this comment block.
+** The arch-tag line is a file identity tag for the GNU Arch
+** revision control system.
+**
+** arch-tag: f1c7eab4-7340-49a8-8deb-0f66de593cdb
+*/