• vxworks下硬盘测速程序 分类: vxWorks 2014-02-27 10:15 537人阅读 评论(0) 收藏




    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);
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    2020牛客多校第十场C-Decrement on the Tree
    2020牛客多校第九场B- Groundhog and Apple Tree
    2020牛客多校第九场J-The Escape Plan of Groundhog
    2020牛客多校第九场E-Groundhog Chasing Death
    2020牛客多校第八场E-Enigmatic Partition
    2020牛客多校第八场A-All Star Game
    2020牛客多校第八场I-Interseting Computer Game
    2020牛客多校第七场H-Dividing
    2020牛客多校第七场J-Pointer Analysis
    2020牛客多校第七场C-A National Pandemic
  • 原文地址:https://www.cnblogs.com/mao0504/p/4706663.html
Copyright © 2020-2023  润新知