diff options
Diffstat (limited to 'gnuradio-core/src/tests')
-rw-r--r-- | gnuradio-core/src/tests/CMakeLists.txt | 72 | ||||
-rwxr-xr-x | gnuradio-core/src/tests/benchmark_dotprod | 46 | ||||
-rw-r--r-- | gnuradio-core/src/tests/benchmark_dotprod_ccc.cc | 151 | ||||
-rw-r--r-- | gnuradio-core/src/tests/benchmark_dotprod_ccf.cc | 153 | ||||
-rw-r--r-- | gnuradio-core/src/tests/benchmark_dotprod_fcc.cc | 152 | ||||
-rw-r--r-- | gnuradio-core/src/tests/benchmark_dotprod_fff.cc | 148 | ||||
-rw-r--r-- | gnuradio-core/src/tests/benchmark_dotprod_fsf.cc | 151 | ||||
-rw-r--r-- | gnuradio-core/src/tests/benchmark_dotprod_scc.cc | 151 | ||||
-rw-r--r-- | gnuradio-core/src/tests/benchmark_nco.cc | 220 | ||||
-rw-r--r-- | gnuradio-core/src/tests/benchmark_vco.cc | 167 | ||||
-rw-r--r-- | gnuradio-core/src/tests/nco_results | 48 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_all.cc | 50 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_atsc.cc | 42 | ||||
-rwxr-xr-x | gnuradio-core/src/tests/test_buffers.py | 136 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_filter.cc | 42 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_general.cc | 42 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_runtime.cc | 42 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_vmcircbuf.cc | 44 |
18 files changed, 1857 insertions, 0 deletions
diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt new file mode 100644 index 000000000..dbd52f05c --- /dev/null +++ b/gnuradio-core/src/tests/CMakeLists.txt @@ -0,0 +1,72 @@ +# Copyright 2010-2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +include(GrMiscUtils) #check n def +GR_CHECK_HDR_N_DEF(sys/resource.h HAVE_SYS_RESOURCE_H) + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${GNURADIO_CORE_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${CPPUNIT_INCLUDE_DIRS} +) + +link_directories( + ${Boost_LIBRARY_DIRS} + ${CPPUNIT_LIBRARY_DIRS} +) + +######################################################################## +# Build benchmarks and non-registered tests +######################################################################## +set(tests_not_run #single source per test + benchmark_dotprod_fff.cc + benchmark_dotprod_fsf.cc + benchmark_dotprod_ccf.cc + benchmark_dotprod_fcc.cc + benchmark_dotprod_scc.cc + benchmark_dotprod_ccc.cc + benchmark_nco.cc + benchmark_vco.cc + test_runtime.cc + test_general.cc + test_filter.cc + #test_atsc.cc + test_vmcircbuf.cc +) + +foreach(test_not_run_src ${tests_not_run}) + get_filename_component(name ${test_not_run_src} NAME_WE) + add_executable(${name} ${test_not_run_src}) + target_link_libraries(${name} test-gnuradio-core) +endforeach(test_not_run_src) + +######################################################################## +# Build the test-all test to end all tests +# Set the test environment so the build libs will be found under MSVC. +######################################################################## +include(GrTest) +list(APPEND GR_TEST_TARGET_DEPS test-gnuradio-core) +add_executable(gr_core_test_all test_all.cc) +target_link_libraries(gr_core_test_all test-gnuradio-core) +GR_ADD_TEST(gr-core-test-all gr_core_test_all) diff --git a/gnuradio-core/src/tests/benchmark_dotprod b/gnuradio-core/src/tests/benchmark_dotprod new file mode 100755 index 000000000..82f3b5c3f --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_dotprod @@ -0,0 +1,46 @@ +#!/bin/sh +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +DIR=. + +tests=" +benchmark_dotprod_fff +benchmark_dotprod_ccf +benchmark_dotprod_ccc +benchmark_dotprod_fcc +benchmark_dotprod_scc +benchmark_dotprod_fsf +" + +echo "uname -a" +uname -a + +if test -e /proc/cpuinfo +then + cat /proc/cpuinfo +fi + +for t in $tests +do + echo + echo "$t": + $DIR/$t +done diff --git a/gnuradio-core/src/tests/benchmark_dotprod_ccc.cc b/gnuradio-core/src/tests/benchmark_dotprod_ccc.cc new file mode 100644 index 000000000..8ef26a40d --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_dotprod_ccc.cc @@ -0,0 +1,151 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_fir_util.h> +#include <gr_fir_ccc.h> +#include <random.h> + +#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) +#define NTAPS 256 +#define BLOCK_SIZE (50 * 1000) /* fits in cache */ + +#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) +#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" +#endif + +typedef gr_fir_ccc* (*fir_maker_t)(const std::vector<gr_complex> &taps); +typedef gr_fir_ccc filter_t; + + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (fir_maker_t filter_maker, const char *implementation_name) +{ + int i; + gr_complex coeffs[NTAPS]; + //gr_complex input[BLOCK_SIZE + NTAPS]; // not always 16-bit aligned + gr_complex *input = new gr_complex[BLOCK_SIZE + NTAPS]; + long n; + gr_complex result; +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + + + // setup coefficients and input data + + for (i = 0; i < NTAPS; i++) + coeffs[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); + + for (i = 0; i < BLOCK_SIZE + NTAPS; i++) + input[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); + + std::vector<gr_complex> taps (&coeffs[0], &coeffs[NTAPS]); + filter_t *f = filter_maker (taps); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start= (double) clock() / CLOCKS_PER_SEC; +#endif + // do the actual work + + for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ + int j; + for (j = 0; j < BLOCK_SIZE; j++){ + result = f->filter ((gr_complex*)&input[j]); + } + } + + // get ending CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double) clock() / CLOCKS_PER_SEC; + double total = clock_end - clock_start; +#endif + + double macs = NTAPS * (double) TOTAL_TEST_SIZE; + + printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", + implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); + + delete f; + delete [] input; +} + +static void +do_all () +{ + std::vector<gr_fir_ccc_info> info; + gr_fir_util::get_gr_fir_ccc_info (&info); // get all known CCC implementations + + for (std::vector<gr_fir_ccc_info>::iterator p = info.begin (); + p != info.end () ; + ++p){ + benchmark (p->create, p->name); + } +} + +int +main (int argc, char **argv) +{ + do_all (); + return 0; +} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_ccf.cc b/gnuradio-core/src/tests/benchmark_dotprod_ccf.cc new file mode 100644 index 000000000..ed3c49165 --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_dotprod_ccf.cc @@ -0,0 +1,153 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_fir_util.h> +#include <gr_fir_ccf.h> +#include <random.h> + +#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) +#define NTAPS 256 +#define BLOCK_SIZE (50 * 1000) /* fits in cache */ + +#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) +#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" +#endif + +typedef gr_fir_ccf* (*fir_maker_t)(const std::vector<float> &taps); +typedef gr_fir_ccf filter_t; + + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (fir_maker_t filter_maker, const char *implementation_name) +{ + int i; + float coeffs[NTAPS]; + //gr_complex input[BLOCK_SIZE + NTAPS]; // not always 16-bit aligned + gr_complex *input = new gr_complex[BLOCK_SIZE + NTAPS]; + long n; + gr_complex result; +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + + // setup coefficients and input data + + for (i = 0; i < NTAPS; i++) + coeffs[i] = random() - RANDOM_MAX/2; + + for (i = 0; i < BLOCK_SIZE + NTAPS; i++) + input[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); + + std::vector<float> taps (&coeffs[0], &coeffs[NTAPS]); + filter_t *f = filter_maker (taps); + + // get starting CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start= (double) clock() / CLOCKS_PER_SEC; +#endif + + // do the actual work + + for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ + int j; + for (j = 0; j < BLOCK_SIZE; j++){ + result = f->filter (&input[j]); + } + } + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end= (double) clock() / CLOCKS_PER_SEC; + double total = clock_end - clock_start; +#endif + + double macs = NTAPS * (double) TOTAL_TEST_SIZE; + + printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", + implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); + + delete f; + delete [] input; +} + +static void +do_all () +{ + std::vector<gr_fir_ccf_info> info; + gr_fir_util::get_gr_fir_ccf_info (&info); // get all known CCF implementations + + for (std::vector<gr_fir_ccf_info>::iterator p = info.begin (); + p != info.end () ; + ++p){ + benchmark (p->create, p->name); + } +} + +int +main (int argc, char **argv) +{ + do_all (); + return 0; +} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_fcc.cc b/gnuradio-core/src/tests/benchmark_dotprod_fcc.cc new file mode 100644 index 000000000..e9eeee43a --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_dotprod_fcc.cc @@ -0,0 +1,152 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_fir_util.h> +#include <gr_fir_fcc.h> +#include <random.h> + +#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) +#define NTAPS 256 +#define BLOCK_SIZE (50 * 1000) /* fits in cache */ + +#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) +#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" +#endif + +typedef gr_fir_fcc* (*fir_maker_t)(const std::vector<gr_complex> &taps); +typedef gr_fir_fcc filter_t; + + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (fir_maker_t filter_maker, const char *implementation_name) +{ + int i; + gr_complex coeffs[NTAPS]; + float input[BLOCK_SIZE + NTAPS]; + long n; + gr_complex result; +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + + + + // setup coefficients and input data + + for (i = 0; i < NTAPS; i++) + coeffs[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); + + for (i = 0; i < BLOCK_SIZE + NTAPS; i++) + input[i] = random() - RANDOM_MAX/2; + + std::vector<gr_complex> taps (&coeffs[0], &coeffs[NTAPS]); + filter_t *f = filter_maker (taps); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + + // do the actual work + + for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ + int j; + for (j = 0; j < BLOCK_SIZE; j++){ + result = f->filter (&input[j]); + } + } + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end= (double) clock() * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + double macs = NTAPS * (double) TOTAL_TEST_SIZE; + + printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", + implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); + + delete f; +} + +static void +do_all () +{ + std::vector<gr_fir_fcc_info> info; + gr_fir_util::get_gr_fir_fcc_info (&info); // get all known FCC implementations + + for (std::vector<gr_fir_fcc_info>::iterator p = info.begin (); + p != info.end () ; + ++p){ + benchmark (p->create, p->name); + } +} + +int +main (int argc, char **argv) +{ + do_all (); + return 0; +} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_fff.cc b/gnuradio-core/src/tests/benchmark_dotprod_fff.cc new file mode 100644 index 000000000..56e064506 --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_dotprod_fff.cc @@ -0,0 +1,148 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif + +#include <unistd.h> +#include <gr_fir_util.h> +#include <gr_fir_fff.h> +#include <random.h> + +#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) +#define NTAPS 256 +#define BLOCK_SIZE (50 * 1000) /* fits in cache */ + +#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) +#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" +#endif + +typedef gr_fir_fff* (*fir_maker_t)(const std::vector<float> &taps); +typedef gr_fir_fff filter_t; + + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (fir_maker_t filter_maker, const char *implementation_name) +{ + int i; + float coeffs[NTAPS]; + float input[BLOCK_SIZE + NTAPS]; + long n; + float result; +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + // setup coefficients and input data + + for (i = 0; i < NTAPS; i++) + coeffs[i] = random() - RANDOM_MAX/2; + + for (i = 0; i < BLOCK_SIZE + NTAPS; i++) + input[i] = random() - RANDOM_MAX/2; + + std::vector<float> taps (&coeffs[0], &coeffs[NTAPS]); + filter_t *f = filter_maker (taps); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + // do the actual work + + for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ + int j; + for (j = 0; j < BLOCK_SIZE; j++){ + result = f->filter (&input[j]); + } + } + + // get ending CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double) clock () * (1000000. / CLOCKS_PER_SEC); + double total = clock_end -clock_start; +#endif + double macs = NTAPS * (double) TOTAL_TEST_SIZE; + + printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", + implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); + + delete f; +} + +static void +do_all () +{ + std::vector<gr_fir_fff_info> info; + gr_fir_util::get_gr_fir_fff_info (&info); // get all known FFF implementations + + for (std::vector<gr_fir_fff_info>::iterator p = info.begin (); + p != info.end (); + ++p){ + + benchmark (p->create, p->name); + } +} + +int +main (int argc, char **argv) +{ + do_all (); + return 0; +} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_fsf.cc b/gnuradio-core/src/tests/benchmark_dotprod_fsf.cc new file mode 100644 index 000000000..a254a8eab --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_dotprod_fsf.cc @@ -0,0 +1,151 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_fir_util.h> +#include <gr_fir_fsf.h> +#include <random.h> + +#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) +#define NTAPS 256 +#define BLOCK_SIZE (50 * 1000) /* fits in cache */ + +#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) +#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" +#endif + +typedef gr_fir_fsf* (*fir_maker_t)(const std::vector<float> &taps); +typedef gr_fir_fsf filter_t; + + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (fir_maker_t filter_maker, const char *implementation_name) +{ + int i; + float coeffs[NTAPS]; + float input[BLOCK_SIZE + NTAPS]; + long n; + short result; +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + + // setup coefficients and input data + + for (i = 0; i < NTAPS; i++) + coeffs[i] = random() - RANDOM_MAX/2; + + for (i = 0; i < BLOCK_SIZE + NTAPS; i++) + input[i] = random() - RANDOM_MAX/2; + + std::vector<float> taps (&coeffs[0], &coeffs[NTAPS]); + filter_t *f = filter_maker (taps); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start= (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + + // do the actual work + + for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ + int j; + for (j = 0; j < BLOCK_SIZE; j++){ + result = f->filter (&input[j]); + } + } + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end= (double) clock() * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + double macs = NTAPS * (double) TOTAL_TEST_SIZE; + + printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", + implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); + + delete f; +} + +static void +do_all () +{ + std::vector<gr_fir_fsf_info> info; + gr_fir_util::get_gr_fir_fsf_info (&info); // get all known FFF implementations + + for (std::vector<gr_fir_fsf_info>::iterator p = info.begin (); + p != info.end (); + ++p){ + + benchmark (p->create, p->name); + } +} + +int +main (int argc, char **argv) +{ + do_all (); + return 0; +} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_scc.cc b/gnuradio-core/src/tests/benchmark_dotprod_scc.cc new file mode 100644 index 000000000..9a65bb4c6 --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_dotprod_scc.cc @@ -0,0 +1,151 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_fir_util.h> +#include <gr_fir_scc.h> +#include <random.h> + +#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) +#define NTAPS 256 +#define BLOCK_SIZE (50 * 1000) /* fits in cache */ + +#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) +#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" +#endif + +typedef gr_fir_scc* (*fir_maker_t)(const std::vector<gr_complex> &taps); +typedef gr_fir_scc filter_t; + + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (fir_maker_t filter_maker, const char *implementation_name) +{ + int i; + gr_complex coeffs[NTAPS]; + short input[BLOCK_SIZE + NTAPS]; + long n; + gr_complex result; +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + + + // setup coefficients and input data + + for (i = 0; i < NTAPS; i++) + coeffs[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); + + for (i = 0; i < BLOCK_SIZE + NTAPS; i++) + input[i] = random() - RANDOM_MAX/2; + + std::vector<gr_complex> taps (&coeffs[0], &coeffs[NTAPS]); + filter_t *f = filter_maker (taps); + + // get starting CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + + // do the actual work + + for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ + int j; + for (j = 0; j < BLOCK_SIZE; j++){ + result = f->filter (&input[j]); + } + } + + // get ending CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end= (double) clock () * (1000000. / CLOCKS_PER_SEC); + double total = clock_end -clock_start; +#endif + + double macs = NTAPS * (double) TOTAL_TEST_SIZE; + + printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", + implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); + + delete f; +} + +static void +do_all () +{ + std::vector<gr_fir_scc_info> info; + gr_fir_util::get_gr_fir_scc_info (&info); // get all known SCC implementations + + for (std::vector<gr_fir_scc_info>::iterator p = info.begin (); + p != info.end () ; + ++p){ + benchmark (p->create, p->name); + } +} + +int +main (int argc, char **argv) +{ + do_all (); + return 0; +} diff --git a/gnuradio-core/src/tests/benchmark_nco.cc b/gnuradio-core/src/tests/benchmark_nco.cc new file mode 100644 index 000000000..20d53e410 --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_nco.cc @@ -0,0 +1,220 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_nco.h> +#include <gr_fxpt_nco.h> +#include <string.h> + +#define ITERATIONS 20000000 +#define BLOCK_SIZE (10 * 1000) // fits in cache + +#define FREQ 5003.123 + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (void test (float *x, float *y), const char *implementation_name) +{ +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + float output[2*BLOCK_SIZE]; + float *x = &output[0], *y = &output[BLOCK_SIZE]; + + // touch memory + memset(output, 0, 2*BLOCK_SIZE*sizeof(float)); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + // do the actual work + + test (x, y); + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double) clock () * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + printf ("%18s: cpu: %6.3f steps/sec: %10.3e\n", + implementation_name, total, ITERATIONS / total); +} + +// ---------------------------------------------------------------- +// Don't compare the _vec with other functions since memory store's +// are involved. + +void basic_sincos_vec (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS/BLOCK_SIZE; i++){ + for (int j = 0; j < BLOCK_SIZE; j++){ + nco.sincos (&x[2*j+1], &x[2*j]); + nco.step (); + } + } +} + +void native_sincos_vec (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS/BLOCK_SIZE; i++){ + nco.sincos ((gr_complex*)x, BLOCK_SIZE); + } +} + +void fxpt_sincos_vec (float *x, float *y) +{ + gr_fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS/BLOCK_SIZE; i++){ + nco.sincos ((gr_complex*)x, BLOCK_SIZE); + } +} + +// ---------------------------------------------------------------- + +void native_sincos (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + nco.sincos (x, y); + nco.step (); + } +} + +void fxpt_sincos (float *x, float *y) +{ + gr_fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + nco.sincos (x, y); + nco.step (); + } +} + +// ---------------------------------------------------------------- + +void native_sin (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + *x = nco.sin (); + nco.step (); + } +} + +void fxpt_sin (float *x, float *y) +{ + gr_fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + *x = nco.sin (); + nco.step (); + } +} + +// ---------------------------------------------------------------- + +void nop_fct (float *x, float *y) +{ +} + +void nop_loop (float *x, float *y) +{ + for (int i = 0; i < ITERATIONS; i++){ + nop_fct (x, y); + } +} + +int +main (int argc, char **argv) +{ + benchmark (nop_loop, "nop loop"); + benchmark (native_sin, "native sine"); + benchmark (fxpt_sin, "fxpt sine"); + benchmark (native_sincos, "native sin/cos"); + benchmark (fxpt_sincos, "fxpt sin/cos"); + benchmark (basic_sincos_vec, "basic sin/cos vec"); + benchmark (native_sincos_vec, "native sin/cos vec"); + benchmark (fxpt_sincos_vec, "fxpt sin/cos vec"); +} diff --git a/gnuradio-core/src/tests/benchmark_vco.cc b/gnuradio-core/src/tests/benchmark_vco.cc new file mode 100644 index 000000000..3a6ade78c --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_vco.cc @@ -0,0 +1,167 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004,2005 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_vco.h> +#include <gr_fxpt_vco.h> +#include <string.h> + +#define ITERATIONS 5000000 +#define BLOCK_SIZE (10 * 1000) // fits in cache + +#define FREQ 5003.123 +#define K 4.9999999 +#define AMPLITUDE 2.444444444 + + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (void test (float *x, const float *y), const char *implementation_name) +{ +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + float output[BLOCK_SIZE]; + float input[BLOCK_SIZE]; + + // touch memory + memset(output, 0, BLOCK_SIZE*sizeof(float)); + for (int i = 0; i<BLOCK_SIZE; i++) + input[i] = sin(double(i)); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + // do the actual work + + test (output, input); + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double) clock () * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + printf ("%18s: cpu: %6.3f steps/sec: %10.3e\n", + implementation_name, total, ITERATIONS / total); +} + +// ---------------------------------------------------------------- + +void basic_vco (float *output, const float *input) +{ + double phase = 0; + + for (int j = 0; j < ITERATIONS/BLOCK_SIZE; j++){ + for (int i = 0; i < BLOCK_SIZE; i++){ + output[i] = cos(phase) * AMPLITUDE; + phase += input[i] * K; + + while (phase > 2 * M_PI) + phase -= 2 * M_PI; + + while (phase < -2 * M_PI) + phase += 2 * M_PI; + } + } +} + +void native_vco (float *output, const float *input) +{ + gr_vco<float,float> vco; + + for (int j = 0; j < ITERATIONS/BLOCK_SIZE; j++){ + vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE); + } + } + +void fxpt_vco (float *output, const float *input) +{ + gr_fxpt_vco vco; + + for (int j = 0; j < ITERATIONS/BLOCK_SIZE; j++){ + vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE); + } +} + +// ---------------------------------------------------------------- + +void nop_fct (float *x, const float *y) +{ +} + +void nop_loop (float *x, const float *y) +{ + for (int i = 0; i < ITERATIONS; i++){ + nop_fct (x, y); + } +} + +int +main (int argc, char **argv) +{ + benchmark (nop_loop, "nop loop"); + benchmark (basic_vco, "basic vco"); + benchmark (native_vco, "native vco"); + benchmark (fxpt_vco, "fxpt vco"); +} diff --git a/gnuradio-core/src/tests/nco_results b/gnuradio-core/src/tests/nco_results new file mode 100644 index 000000000..5bdf5dd1c --- /dev/null +++ b/gnuradio-core/src/tests/nco_results @@ -0,0 +1,48 @@ +================================================================ +These are on a 1.4 GHz Pentium M using g++ 3.4.1 +================================================================ + +Default compiler options -O2 + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.900 steps/sec: 1.111e+07 + fxpt sine: cpu: 0.281 steps/sec: 3.559e+07 + native sin/cos: cpu: 1.138 steps/sec: 8.789e+06 + fxpt sin/cos: cpu: 0.550 steps/sec: 1.818e+07 + +-O2 -march=pentium-m -fomit-frame-pointer + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.903 steps/sec: 1.108e+07 + fxpt sine: cpu: 0.271 steps/sec: 3.691e+07 + native sin/cos: cpu: 1.092 steps/sec: 9.159e+06 + fxpt sin/cos: cpu: 0.542 steps/sec: 1.845e+07 + +Inlined fxpt::sin & cos +-O2 -march=pentium-m -fomit-frame-pointer + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.904 steps/sec: 1.106e+07 + fxpt sine: cpu: 0.187 steps/sec: 5.348e+07 + native sin/cos: cpu: 1.091 steps/sec: 9.167e+06 + fxpt sin/cos: cpu: 0.373 steps/sec: 2.681e+07 + +================================================================ +These are on a 1.5 GHz Athon MP 1800+ +================================================================ + +Default compiler options: -O2 + + nop loop: cpu: 0.013 steps/sec: 7.693e+08 + native sine: cpu: 0.733 steps/sec: 1.364e+07 + fxpt sine: cpu: 0.210 steps/sec: 4.763e+07 + native sin/cos: cpu: 1.183 steps/sec: 8.454e+06 + fxpt sin/cos: cpu: 0.420 steps/sec: 2.381e+07 + +-O2 -fomit-frame-pointer -march=athlon-mp + + nop loop: cpu: 0.013 steps/sec: 7.693e+08 + native sine: cpu: 0.679 steps/sec: 1.473e+07 + fxpt sine: cpu: 0.200 steps/sec: 5.001e+07 + native sin/cos: cpu: 1.147 steps/sec: 8.720e+06 + fxpt sin/cos: cpu: 0.444 steps/sec: 2.253e+07 diff --git a/gnuradio-core/src/tests/test_all.cc b/gnuradio-core/src/tests/test_all.cc new file mode 100644 index 000000000..8a1423e9e --- /dev/null +++ b/gnuradio-core/src/tests/test_all.cc @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2010,2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> +#include <qa_runtime.h> +#include <qa_general.h> +#include <qa_filter.h> +// #include <qa_atsc.h> + +// FIXME add atsc back in. + +int +main (int argc, char **argv) +{ + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(get_unittest_path("gnuradio_core_all.xml").c_str()); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); + + runner.addTest (qa_runtime::suite ()); + runner.addTest (qa_general::suite ()); + runner.addTest (qa_filter::suite ()); + // runner.addTest (qa_atsc::suite ()); + runner.setOutputter(xmlout); + + bool was_successful = runner.run ("", false); + + return was_successful ? 0 : 1; +} diff --git a/gnuradio-core/src/tests/test_atsc.cc b/gnuradio-core/src/tests/test_atsc.cc new file mode 100644 index 000000000..d99bccce5 --- /dev/null +++ b/gnuradio-core/src/tests/test_atsc.cc @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> +#include <qa_atsc.h> + +int +main (int argc, char **argv) +{ + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(get_unittest_path("gnuradio_core_atsc.xml").c_str()); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); + + runner.addTest (qa_atsc::suite ()); + runner.setOutputter(xmlout); + + bool was_successful = runner.run ("", false); + + return was_successful ? 0 : 1; +} diff --git a/gnuradio-core/src/tests/test_buffers.py b/gnuradio-core/src/tests/test_buffers.py new file mode 100755 index 000000000..b867c727c --- /dev/null +++ b/gnuradio-core/src/tests/test_buffers.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python +# +# Copyright 2006 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gru +from gnuradio import audio +from gnuradio.eng_option import eng_option +from optparse import OptionParser + +import time +import sys + +# Test script to test setting up the buffers using gr_test +# For very large buffers it will fail when you hit the circbuf memory limit. +# On linux this limit is shmmax, it will fail when it tries to create a buffer > shmmax. +# With a 2.6 or later kernel you can set the shmmax limit manually in a root console +#show current shmmax limit +#$ cat /proc/sys/kernel/shmmax +#33554432 + +#set shmmax limit manually to 300MB +#echo 300000000 >/proc/sys/kernel/shmmax + +#show new shmmax limit +#$ cat /proc/sys/kernel/shmmax +#300000000 + +class my_graph(gr.top_block): + + def __init__(self, seconds,history,output_multiple): + gr.top_block.__init__(self) + + parser = OptionParser(option_class=eng_option) + parser.add_option("-O", "--audio-output", type="string", default="", + help="pcm output device name. E.g., hw:0,0 or /dev/dsp") + parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, + help="set sample rate to RATE (48000)") + (options, args) = parser.parse_args () + if len(args) != 0: + parser.print_help() + raise SystemExit, 1 + + sample_rate = int(options.sample_rate) + ampl = 0.1 + + src0 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 350, ampl) + + nsamples=int(sample_rate * seconds) #1 seconds + # gr.test (const std::string &name=std::string("gr_test"), + # int min_inputs=1, int max_inputs=1, unsigned int sizeof_input_item=1, + # int min_outputs=1, int max_outputs=1, unsigned int sizeof_output_item=1, + # unsigned int history=1,unsigned int output_multiple=1,double relative_rate=1.0, + # bool fixed_rate=true,gr_consume_type_t cons_type=CONSUME_NOUTPUT_ITEMS, gr_produce_type_t prod_type=PRODUCE_NOUTPUT_ITEMS); + name="gr_test" + min_inputs=1 + max_inputs=1 + sizeof_input_item=gr.sizeof_float + min_outputs=1 + max_outputs=1 + sizeof_output_item=gr.sizeof_float + #history=1 # problems start at 8150 + #output_multiple=1 #problems start at 8000 in combination with large history + relative_rate=1.0 + fixed_rate=True + consume_type=gr.CONSUME_NOUTPUT_ITEMS + produce_type=gr.PRODUCE_NOUTPUT_ITEMS + test = gr.test(name, min_inputs,max_inputs,sizeof_input_item, + min_outputs,max_outputs,sizeof_output_item, + history,output_multiple,relative_rate, + fixed_rate, consume_type,produce_type) + #test = gr.test("gr_test",1,1,gr.sizeof_float, + # 1,1,gr.sizeof_float, + # 1,1,1.0, + # True, gr.CONSUME_NOUTPUT_ITEMS,gr.PRODUCE_NOUTPUT_ITEMS) + #unsigned int history=1,unsigned int output_multiple=1,double relative_rate=1.0, + #bool fixed_rate=false + dst = audio.sink (sample_rate, options.audio_output) + head= gr.head(gr.sizeof_float, nsamples) + + self.connect (src0,test,head,(dst, 0)) + + +if __name__ == '__main__': + + seconds=5.0 + output_multiple=1 + for history in (1,1000,8000,8100,8150,8175,8190,8191,8192,8193,8194,8195,9000,10000,100000,1000000,10000000): #,100000000): + sys.stdout.flush() + sys.stderr.flush() + print 'Test with history=', history, 'output_multiple=',output_multiple + sys.stdout.flush() + sys.stderr.flush() + succeed=True + starttime=time.time() + try: + my_graph(seconds,history,output_multiple).run() + except KeyboardInterrupt: + pass + except: + print "\nAn exception has terminated the graph." + exception=True + succeed=False + sys.stdout.flush() + sys.stderr.flush() + if succeed: + print '' + endtime=time.time() + duration=endtime - starttime + if (duration < 0.5*seconds) and (succeed): + print "A problem has terminated the graph." + succeed=False + if (duration > 1.5*seconds) and (succeed): + print "Something slowed the graph down considerably." + succeed=False + + print 'The test result was:' , succeed + print 'Test duration' , duration + print '' diff --git a/gnuradio-core/src/tests/test_filter.cc b/gnuradio-core/src/tests/test_filter.cc new file mode 100644 index 000000000..8b17034c6 --- /dev/null +++ b/gnuradio-core/src/tests/test_filter.cc @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2010,2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> +#include <qa_filter.h> + +int +main (int argc, char **argv) +{ + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(get_unittest_path("gnuradio_core_filter.xml").c_str()); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); + + runner.addTest (qa_filter::suite ()); + runner.setOutputter(xmlout); + + bool was_successful = runner.run ("", false); + + return was_successful ? 0 : 1; +} diff --git a/gnuradio-core/src/tests/test_general.cc b/gnuradio-core/src/tests/test_general.cc new file mode 100644 index 000000000..32fac1b35 --- /dev/null +++ b/gnuradio-core/src/tests/test_general.cc @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2010,2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> +#include <qa_general.h> + +int +main (int argc, char **argv) +{ + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(get_unittest_path("gnuradio_core_general.xml").c_str()); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); + + runner.addTest (qa_general::suite ()); + runner.setOutputter(xmlout); + + bool was_successful = runner.run ("", false); + + return was_successful ? 0 : 1; +} diff --git a/gnuradio-core/src/tests/test_runtime.cc b/gnuradio-core/src/tests/test_runtime.cc new file mode 100644 index 000000000..bd5378332 --- /dev/null +++ b/gnuradio-core/src/tests/test_runtime.cc @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2010,2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> +#include <qa_runtime.h> + +int +main (int argc, char **argv) +{ + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(get_unittest_path("gnuradio_core_runtime.xml").c_str()); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); + + runner.addTest (qa_runtime::suite ()); + runner.setOutputter(xmlout); + + bool was_successful = runner.run ("", false); + + return was_successful ? 0 : 1; +} diff --git a/gnuradio-core/src/tests/test_vmcircbuf.cc b/gnuradio-core/src/tests/test_vmcircbuf.cc new file mode 100644 index 000000000..ee24b6d62 --- /dev/null +++ b/gnuradio-core/src/tests/test_vmcircbuf.cc @@ -0,0 +1,44 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <gr_vmcircbuf.h> +#include <stdio.h> + +int +main (int argc, char **argv) +{ + int verbose = 1; // summary + + if (argc > 1) + verbose = 2; // extra chatty + + bool ok = gr_vmcircbuf_sysconfig::test_all_factories (verbose); + + if (ok){ + fprintf (stdout, "test_vmcircbuf: OK. We've got at least one workable solution\n"); + return 0; + } + else { + fprintf (stdout, "test_vmcircbuf: NOT OK. We don't have a workable solution\n"); + return 1; + } +} |