void speed(int buflen,int mod)
{
/*int mod = 0;*/
int len=50;
FILE *fp;
unsigned int i=0,j=0,tmp,tmp2;
float t=0.0;
char *str = "/ata00/ch2.dat";
char* data = (char*)malloc(buflen);
if(mod ==0)
{
str ="/bd0/ch2.dat";
len = 50;
}
else if(mod==1)
str ="/ata00/ch2.dat";
else
str="/ata00:2/mx.dat";
for(i=0;i<buflen;i++)
{
data[i] = i&0xff;
}
fp=fopen(str,"w+");
if(fp==NULL)
{
logMsg("fopen error ",0,0,0,0,0,0);
return;
}
/*printf("test '%s' speed %dM data writted! ",str,len);*/
if(buflen>1024)
logMsg("test '%s' speed %dM data writted(buflen:%dK)! ",str,len,buflen/1024,0,0,0);
else
logMsg("test '%s' speed %dM data writted(buflen:%d)! ",str,len,buflen,0,0,0);
tmp = tickGet();
i = 1024*len*1024/buflen;
for(j=0;j<i;j++)
{
fwrite(data,buflen,1,fp);
}
fclose(fp);
tmp = tickGet()-tmp ;
t = tmp*1.0/60;
/* printf("Write speed:%f MB/s (%dM/%ds)",len*1.0/tmp,len,tmp);*/
logMsg("Write speed:%3.2f MB/s (%dM/%2.2fs) ",len*1.0/t,len,t,0,0,0);
taskDelay(60*1);
fp=fopen(str,"r+");
tmp = tickGet();
i = 1024*len*1024/buflen;
for(j=0;j<i;j++)
{
fread(data,buflen,1,fp);
}
fclose(fp);
tmp = tickGet()-tmp ;
t = tmp*1.0/60;
/* printf(" Read speed:%f MB/s (%dM/%ds) ",len*1.0/tmp,len,tmp);*/
logMsg(" Read speed:%3.2f MB/s (%dM/%2.2fs) ",len*1.0/t,len,t,0,0,0);
}
void speed3()
{//SATA
int i=0;
for(i=0;i<10;i++)
speed(2<<i,4);
for(i=0;i<10;i++)
speed((2<<i)*1024,4);
}
void speed4()
{//usb
int i=0;
for(i=0;i<10;i++)
speed(2<<i,0);
for(i=0;i<10;i++)
speed((2<<i)*1024,0);
}
版权声明:本文为博主原创文章,未经博主允许不得转载。