JASPL  0.2
Just Another Signal Processing Library
perf_jfft.h
1 #ifndef JFFT_UNIT_TEST_H
2 #define JFFT_UNIT_TEST_H
3 
4 //Header for this file
5 //
6 //C System-Headers
7 #include <math.h>
8 //C++ System headers
9 #include <iostream>
10 #include <chrono>
11 //OpenCL Headers
12 //
13 //Boost Headers
14 //
15 //Project specific headers
16 #include "jVector/jvector.h"
17 #include "jFFT/jfft.h"
18 #include "jPlot/jplot.h"
19 
20 namespace jaspl {
21 
22 std::vector< float > build_test_signal( uint N ) {
23 
24  std::vector< float > sin_vect ( N );
25 
26  for ( uint i = 0; i < N ; i++ ) {
27 
28  sin_vect.push_back( sinf( (5)*i *2*M_PI/N) + 2*sinf( (25)*i*2*M_PI/N) + 3*sinf( (50)*i*2*M_PI/N ) );
29  }
30 
31  return sin_vect;
32 }
33 
34 void PerfJFFT() {
35 
36  const uint signal_size = 10000;
37 
38  JFFT< std::vector < float > > fft_er( true );
39 
40  std::vector< float > signal = build_test_signal( signal_size );
41 
42  auto start_cpu = std::chrono::high_resolution_clock::now();
43 
44  fft_er.PowerSpectrum( signal );
45 
46  auto end_cpu = std::chrono::high_resolution_clock::now();
47  std::chrono::duration<double, std::milli> cpu_ms = end_cpu - start_cpu;
48  auto time_taken_cpu = cpu_ms.count();
49 
50  std::cout<<"CPU took "<<time_taken_cpu<<" ms."<<std::endl;
51 
52 }
53 
54 }
55 
56 #endif // JFFT_UNIT_TEST_H