?? test_speedfft.cpp
字號:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
extern "C" double currTime();
extern "C" void cdft(int n, int isgn, double *a);
void initTestData(double data[],int len)
{
/* pre code
int i;
for (i=0;i<len;i++)
{
data[2*i]=(double)(rand() % 1000);
data[2*i+1]=(double)(rand() % 1000);
}
*/
//add by tonnyue
memset(data, len, sizeof(double));
srand( (unsigned)time( NULL ) );
data[rand()%1000]=1;
data[rand()%1000]=1;
data[rand()%1000]=1;
//end add
}
void testSpeed_oouraFFT(int maxLen)
{
int len,c;
double k,t,tmp;
double *data=NULL;
FILE *fp=fopen("benchmark.txt","wt");
if (fp==NULL)
return;
data=new double[maxLen*2];
if (data==NULL)
return ;
t=currTime();
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)
{
tmp=currTime();
cdft(len*2,-1,data);
t+=currTime()-tmp;
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);
if (data!=NULL)
delete[] data;
}
int main()
{
testSpeed_oouraFFT(2*1048576);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -