?? test_fft.cpp
字號:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
extern "C" double currTime();
void four1(double data[], int nn, int isign);
void initTestData(double data[],int len)
{
int i;
for (i=1;i<=len*2;i+=2) //base 1
{
data[i]=(double)(rand() % 1000);
data[i+1]=(double)(rand() % 1000);
}
}
void testSpeed_fft(int maxLen)
{
int len,c;
double *data = new double[maxLen*2+2];
FILE *fp;
double k,t,tmp1;
if (data==NULL)
{
printf("No enough memory to alloc\n");
}
fp=fopen("benchmark.txt","wt");
if (fp==NULL)
return;
fprintf(fp," len \tfft time \ttime/(n*log2(n)\n");
for (len=64;len<=maxLen;len*=2)
{
t=0.0;
c=0;
initTestData(data,len);
while (true)
{
tmp1=currTime();
four1(data, len, 1);
t+=currTime()-tmp1;
c++;
if (t>0.001)
break;
}
t/=c;
k=t/(len*log10(len)/log10(2));
fprintf(fp,"%8d,\t%.8f \t%.12f\n",len,t,k);
}
fclose(fp);
delete[] data;
}
int main()
{
testSpeed_fft(2*1048576);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -