1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-17 20:53:02 +00:00

Add Gnuplot-based plot results for FFT MeasureExecutionTime test

This commit is contained in:
Carles Fernandez 2017-10-21 13:05:51 +02:00
parent 1ac986e207
commit ff4938702e
3 changed files with 2025 additions and 3 deletions

View File

@ -158,6 +158,11 @@ if(ENABLE_FPGA)
add_definitions(-DFPGA_BLOCKS_TEST=1) add_definitions(-DFPGA_BLOCKS_TEST=1)
endif(ENABLE_FPGA) endif(ENABLE_FPGA)
find_package(Gnuplot)
if(GNUPLOT_FOUND)
add_definitions(-DGNUPLOT_EXECUTABLE="${GNUPLOT_EXECUTABLE}")
endif(GNUPLOT_FOUND)
################################################################################ ################################################################################
# Optional generator # Optional generator
################################################################################ ################################################################################

File diff suppressed because it is too large Load Diff

View File

@ -33,14 +33,26 @@
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include <random> #include <random>
#include <boost/filesystem.hpp>
#include <gnuradio/fft/fft.h> #include <gnuradio/fft/fft.h>
#if defined GNUPLOT_EXECUTABLE
#include "gnuplot_i.h"
const bool exists_gnuplot_fft_test_length = true;
#elif !defined GNUPLOT_EXECUTABLE
const bool exists_gnuplot_fft_test_length = false;
#endif
DEFINE_int32(fft_iterations_test, 1000, "Number of averaged iterations in FFT length timing test"); DEFINE_int32(fft_iterations_test, 1000, "Number of averaged iterations in FFT length timing test");
DEFINE_bool(plot_fft_length_test, false, "Plots results of FFTLengthTest");
TEST(FFTLengthTest, MeasureExecutionTime) TEST(FFTLengthTest, MeasureExecutionTime)
{ {
unsigned int fft_sizes [] = { 1000, 1024, 1960, 2000, 2048, 4000, 4096, 4725, 5000, 8000, 8192, 10368, 12000, 16000, 16384, 27000, 32768, 50000, 65536 }; unsigned int fft_sizes [] = { 512, 1000, 1024, 1100, 1297, 1400, 1500, 1960, 2000, 2048, 2221, 2500, 3000, 3500, 4000,
4096, 4200, 4500, 4725, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8192, 8500, 9000, 9500, 10000, 10368, 11000,
12000, 15000, 16000, 16384, 27000, 32768, 50000, 65536 };
std::chrono::time_point<std::chrono::system_clock> start, end; std::chrono::time_point<std::chrono::system_clock> start, end;
@ -54,8 +66,12 @@ TEST(FFTLengthTest, MeasureExecutionTime)
auto gen = std::bind(func, random_number1, random_number2); // Function that returns a random gr_complex auto gen = std::bind(func, random_number1, random_number2); // Function that returns a random gr_complex
std::vector<unsigned int> fft_sizes_v(fft_sizes, fft_sizes + sizeof(fft_sizes) / sizeof(unsigned int) ); std::vector<unsigned int> fft_sizes_v(fft_sizes, fft_sizes + sizeof(fft_sizes) / sizeof(unsigned int) );
std::sort(fft_sizes_v.begin(), fft_sizes_v.end());
std::vector<unsigned int>::const_iterator it; std::vector<unsigned int>::const_iterator it;
unsigned int d_fft_size; unsigned int d_fft_size;
std::vector<double> execution_times;
std::vector<unsigned int> powers_of_two;
std::vector<double> execution_times_powers_of_two;
EXPECT_NO_THROW( EXPECT_NO_THROW(
for(it = fft_sizes_v.cbegin(); it != fft_sizes_v.cend(); ++it) for(it = fft_sizes_v.cbegin(); it != fft_sizes_v.cend(); ++it)
@ -73,9 +89,57 @@ TEST(FFTLengthTest, MeasureExecutionTime)
} }
end = std::chrono::system_clock::now(); end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start; std::chrono::duration<double> elapsed_seconds = end - start;
double execution_time = elapsed_seconds.count() / static_cast<double>(FLAGS_fft_iterations_test); double exec_time = elapsed_seconds.count() / static_cast<double>(FLAGS_fft_iterations_test);
std::cout << "FFT execution time for length=" << d_fft_size << " : " << execution_time << " [s]" << std::endl; execution_times.push_back(exec_time * 1e3);
std::cout << "FFT execution time for length=" << d_fft_size << " : " << exec_time << " [s]" << std::endl;
delete d_fft; delete d_fft;
if( (d_fft_size & (d_fft_size - 1)) == 0 ) // if it is a power of two
{
powers_of_two.push_back(d_fft_size);
execution_times_powers_of_two.push_back(exec_time / 1e-3);
}
} }
); );
if(FLAGS_plot_fft_length_test == true)
{
if(!exists_gnuplot_fft_test_length)
{
std::cout << "WARNING: Although the flag plot_fft_length_test has been set to TRUE," << std::endl;
std::cout << "gnuplot has not been found in your system." << std::endl;
std::cout << "Test results will not be plotted." << std::endl;
}
else
{
#if defined GNUPLOT_EXECUTABLE
std::string gnuplot_executable = std::string(GNUPLOT_EXECUTABLE);
boost::filesystem::path p(gnuplot_executable);
boost::filesystem::path dir = p.parent_path();
std::string gnuplot_path = dir.native();
Gnuplot::set_GNUPlotPath(gnuplot_path);
Gnuplot g1("linespoints");
g1.set_title("FFT execution times for different lengths");
g1.set_grid();
g1.set_xlabel("FFT length");
g1.set_ylabel("Execution time [ms]");
g1.plot_xy(fft_sizes_v, execution_times, "FFT execution time (averaged over " + std::to_string(FLAGS_fft_iterations_test) + " iterations)");
g1.set_style("points").plot_xy(powers_of_two, execution_times_powers_of_two, "Power of 2");
g1.showonscreen(); // window output
Gnuplot g2("linespoints");
g2.set_title("FFT execution times for different lengths (up to 2^{14}=16384)");
g2.set_grid();
g2.set_xlabel("FFT length");
g2.set_ylabel("Execution time [ms]");
g2.set_xrange(0, 16384);
g2.plot_xy(fft_sizes_v, execution_times, "FFT execution time (averaged over " + std::to_string(FLAGS_fft_iterations_test) + " iterations)");
g2.set_style("points").plot_xy(powers_of_two, execution_times_powers_of_two, "Power of 2");
g2.savetops("FFT_execution_times");
g2.showonscreen(); // window output
#endif
}
}
} }