1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-29 10:24:51 +00:00

Added FFT speed test

Unit test comparing GNU Radio and Armadillo FFT implementations
This commit is contained in:
Unknown 2017-10-18 11:04:17 +02:00
parent 2c739a26bf
commit d5590eefe4

View File

@ -35,7 +35,6 @@
#include <gnuradio/fft/fft.h>
#include <armadillo>
DEFINE_int32(fft_speed_iterations_test, 1000, "Number of averaged iterations in FFT length timing test");
TEST(FFTSpeedTest, ArmadilloVSGNURadioExecutionTime)
@ -44,19 +43,17 @@ TEST(FFTSpeedTest, ArmadilloVSGNURadioExecutionTime)
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
unsigned int fft_sizes [13] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 };
unsigned int fft_sizes [19] = { 16, 25, 32, 45, 64, 95, 128, 195, 256, 325, 512, 785, 1024, 1503, 2048, 3127, 4096, 6349, 8192 };
double d_execution_time;
EXPECT_NO_THROW(
for(int i = 0; i < 13; i++)
for(int i = 0; i < 19; i++)
{
d_fft_size = fft_sizes[i];
gr::fft::fft_complex* d_gr_fft;
d_gr_fft = new gr::fft::fft_complex(d_fft_size, true);
arma::cx_vec d_arma_fft(d_fft_size);
d_arma_fft = arma::cx_vec(d_fft_size).randn() + gr_complex(0.0, 1.0) * arma::cx_vec(d_fft_size).randn();
arma::arma_rng::set_seed_random();
arma::cx_fvec d_arma_fft = arma::cx_fvec(d_fft_size).randn() + gr_complex(0.0, 1.0) * arma::cx_fvec(d_fft_size).randn();
arma::cx_fvec d_arma_fft_result(d_fft_size);
memcpy(d_gr_fft->get_inbuf(), d_arma_fft.memptr(), sizeof(gr_complex) * d_fft_size);
start = std::chrono::system_clock::now();
@ -67,18 +64,18 @@ TEST(FFTSpeedTest, ArmadilloVSGNURadioExecutionTime)
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
d_execution_time = elapsed_seconds.count() / static_cast<double>(FLAGS_fft_speed_iterations_test);
std::cout << "GNU Radio FFT execution time for length = " << d_fft_size << " : " << d_execution_time << " [s]" << std::endl;
std::cout << "GNU Radio FFT execution time for length = " << d_fft_size << " : " << d_execution_time * 1e6 << " [us]" << std::endl;
delete d_gr_fft;
start = std::chrono::system_clock::now();
for(int k = 0; k < FLAGS_fft_speed_iterations_test; k++)
{
arma::fft(d_arma_fft);
}
d_arma_fft_result = arma::fft(d_arma_fft);
}
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
d_execution_time = elapsed_seconds.count() / static_cast<double>(FLAGS_fft_speed_iterations_test);
std::cout << "Armadillo FFT execution time for length = " << d_fft_size << " : " << d_execution_time << " [s]" << std::endl;
std::cout << "Armadillo FFT execution time for length = " << d_fft_size << " : " << d_execution_time * 1e6 << " [us]" << std::endl;
}
);
}