From 394048f5e7fc33e79122af38ac03a8d9967d1026 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 26 May 2016 19:30:14 +0200 Subject: [PATCH] Add test of FFT execution times for different lengths --- src/tests/arithmetic/fft_length_test.cc | 66 +++++++++++++++++++++++++ src/tests/test_main.cc | 1 + 2 files changed, 67 insertions(+) create mode 100644 src/tests/arithmetic/fft_length_test.cc diff --git a/src/tests/arithmetic/fft_length_test.cc b/src/tests/arithmetic/fft_length_test.cc new file mode 100644 index 000000000..649cd7a90 --- /dev/null +++ b/src/tests/arithmetic/fft_length_test.cc @@ -0,0 +1,66 @@ +/*! + * \file fft_length_test.cc + * \brief This file implements timing tests for the FFT. + * \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2016 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR 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 of the License, or + * (at your option) any later version. + * + * GNSS-SDR 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 GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include +#include + + +DEFINE_int32(fft_iterations_test, 1000, "Number of averaged iterations in FFT length timing test"); + +TEST(FFT_Length_Test, MeasureExecutionTime) +{ + unsigned int d_fft_size; + struct timeval tv; + + unsigned int fft_sizes [18] = { 1000, 1024, 1960, 2000, 2048, 4000, 4096, 4725, 8000, 8192, 10368, 12000, 16000, 16384, 27000, 32768, 50000, 65536 }; + double execution_times [18]; + EXPECT_NO_THROW( + for(int i = 0; i < 18; i++) + { + gr::fft::fft_complex* d_fft; + d_fft_size = fft_sizes[i]; + d_fft = new gr::fft::fft_complex(d_fft_size, true); + std::fill_n( d_fft->get_inbuf(), d_fft_size, gr_complex( 0.0, 0.0 ) ); + + gettimeofday(&tv, NULL); + long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; + for(int k = 0; k < FLAGS_fft_iterations_test; k++) + { + d_fft->execute(); + } + gettimeofday(&tv, NULL); + long long int end = tv.tv_sec * 1000000 + tv.tv_usec; + execution_times[i] = static_cast(end - begin) / (1000000.0 * static_cast(FLAGS_fft_iterations_test)); + std::cout << "FFT execution time for length=" << d_fft_size << " : " << execution_times[i] << " [s]" << std::endl; + delete d_fft; + } + ); +} diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index d55a88a45..a3dabce30 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -75,6 +75,7 @@ DECLARE_string(log_dir); #include "arithmetic/multiply_test.cc" #include "arithmetic/code_generation_test.cc" #include "arithmetic/tracking_loop_filter_test.cc" +#include "arithmetic/fft_length_test.cc" #include "configuration/file_configuration_test.cc" #include "configuration/in_memory_configuration_test.cc" #include "control_thread/control_message_factory_test.cc"