28 #define SAMPLE_RATE 48000 38 #include <sys/types.h> 53 gettimeofday(&tp, NULL);
54 ret = ((double) tp.tv_sec) + 1e-6*((double)tp.tv_usec);
58 complex<float>
doWork(complex<float> * in, complex<float> * out,
unsigned int vsize)
60 complex<float> ret(0.0,0.0);
62 fftwf_plan plan = fftwf_plan_dft_1d(vsize, (fftwf_complex*) in, (fftwf_complex*) out,
63 FFTW_FORWARD, FFTW_ESTIMATE);
69 for(
int i = 0; i < 100; i++) {
77 double ttime = (endt - startt)/100;
78 double time_per_point = ttime / ((double) vsize);
79 printf(
"%d %g %g\n", vsize, ttime, time_per_point);
82 fftwf_destroy_plan(plan);
87 int main(
int argc,
char * argv[])
89 (void) argc; (void) argv;
93 static int maxbuf = 1000000;
94 complex<float> * invec;
95 complex<float> * outvec;
97 invec = (complex<float>*) fftwf_malloc(maxbuf *
sizeof(complex<float>));
98 outvec = (complex<float>*) fftwf_malloc(maxbuf *
sizeof(complex<float>));
101 float anginc = M_PI * 20.0;
104 for(i = 0; i < maxbuf; i++) {
105 invec[i] = complex<float>(cos(ang), sin(ang));
107 if(ang > M_PI) ang -= (2.0 * M_PI);
111 unsigned int vecsize;
112 complex<float> rsum(0.0,0.0);
113 for(vecsize = 32; vecsize <= 50000; vecsize *= 2) {
114 rsum +=
doWork(invec, outvec, vecsize);
116 for(vecsize = 48; vecsize <= 50000; vecsize *= 2) {
117 rsum +=
doWork(invec, outvec, vecsize);
119 unsigned int ivs[] = { 625, 1250, 2500, 3125, 5000, 15625, 78125, 390625, 0 };
120 for(i = 0; ivs[i] > 0; i++) {
121 rsum +=
doWork(invec, outvec, ivs[i]);
123 rsum +=
doWork(invec, outvec, 30000 + 1250);
124 rsum +=
doWork(invec, outvec, 30000);
125 rsum +=
doWork(invec, outvec, 32768);
126 rsum +=
doWork(invec, outvec, 48 * 48);
130 for(i = 0; i < 100; i++) {
131 memcpy(invec, outvec, 30000 *
sizeof(complex<float>));
134 memcpy(outvec, invec, 30000 *
sizeof(complex<float>));
136 outvec[i*2+3] *= rsum;
139 double timet = endt - startt;
141 printf(
"memcpy bandwidth %g sec for a 30K long vector, %g sec per sample.\n",
142 timet / 200.0, timet / (200.0 * 30000.0));
144 printf(
"dummy print = %f %f\n", rsum.real(), rsum.imag());
int main(int argc, char *argv[])
complex< float > doWork(complex< float > *in, complex< float > *out, unsigned int vsize)