最近,我想编写测试闪存盘读写速度的软件,不知道这样的思路是否正确,请大家帮助分析:通过编写程序向闪存盘中拷贝一个文件,获得拷贝时间后,最终计算速度.(kB/s)

解决方案 »

  1.   

    复制文件用2进制写,分别测试闪存盘不同大小区块文件的性能。以 4K 为大小写一个大于30M的文件,计算总用时
    以 32K 为大小写一个大于30M的文件,计算总用时
    以 128K 为大小写一个大于30M的文件,计算总用时
    以 1024K 为大小写一个大于30M的文件,计算总用时
    以 4096K 为大小写一个大于30M的文件,计算总用时最后加权计算得分读文件的道理一样
      

  2.   

    首先谢谢您的回答,我用下面这个API函数实现复制文件
    Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    请问大于30M有什么说法吗?
      

  3.   

    复制文件的过程自己写,不要用任何外部APIopen "" for binary as #1
      

  4.   

    我是这样编写读写程序的,但是程序执行完毕后,目标文件中并没有写入任何的内容,这是为什么?其中源文件(1024.txt)中有512个汉字,即1024KB.
    Private Sub Command1_Click()
       Dim bytedata() As Byte
       Dim sourcefile1, sourcefile2 As Long
       dim block1 as long   block1 = 512
       sourcefile1 = FreeFile
       sourcefile2 = FreeFile + 1
       Open "c:\1024.txt" For Binary Access Read As sourcefile1
       Open "c:\zjgl.txt" For Binary Access Write As sourcefile2
       ReDim bytedata(block1)
       Get sourcefile1, , bytedata(block1)
       Put sourcefile2, , bytedata(block1)
       Close sourcefile1
       Close sourcefile2
    End Sub
      

  5.   

    谢谢,我自己研究出来了.
    Private Sub Command1_Click()
       Dim bytedata() As Byte
       Dim sourcefile1, sourcefile2 As Long
          block1 = 512
       sourcefile1 = FreeFile
       sourcefile2 = FreeFile + 1
       Open "c:\1024.txt" For Binary Access Read As sourcefile1
       Open "c:\zjgl.txt" For Binary Access Write As sourcefile2
       ReDim bytedata(1 To LOF(sourcefile1))
       Get sourcefile1, , bytedata()
       Put sourcefile2, , bytedata()
       Close sourcefile1
       Close sourcefile2
    End Sub
      

  6.   

    我想问一下,这种方法行吗?比我调用API函数执行复制文件,写的速度要快很多.是否仍有更快的方法?此外,加权,您有什么好的方法.
      

  7.   

    1:应该这么写  Dim sourcefile1 As Long, sourcefile2 As Long
    2:你仅仅只读写了 512 字节,速度当然快
    等周一我上班了再给你代码
      

  8.   

    您看我这样的想法正确吗?1.测试闪存盘的数据写入速度
      从计算机硬盘上复制文件到闪存盘,计算总时间,进而得到闪存盘数据写入速度.是否此时,我也得到了计算机硬盘的数据读取速度.
    2.测试闪存盘的数据读取速度
      从闪存盘上复制文件到计算机硬盘,计算总时间,进而得到闪存盘的数据读取速度.是否此时,我也得到了计算机硬盘的数据写入速度.测试闪存盘的数据写入速度,源程序如下(向闪存盘中写入一个30M大小的文件,每次写1M,分30次):
    Private Sub comstart3_Click()Dim SHFileOp As SHFILEOPSTRUCT
    Dim temp_old, temp_new, temp_sub As Date
    Dim temp_s As Integer
    Dim i As Long
    Dim temp_ratio As Integer
    Dim temp_h, temp_m As Integer
    Dim temp_sum As Integer
    Dim temp_num1 As Long
    Dim temp_num2 As Long
    Dim temp_a As Long
    Dim temp_b As LongSHFileOp.wFunc = FO_COPY
    temp_old = CDate(Now)
    For i = 1 To 32
      SHFileOp.pFrom = "c:\1024.txt"
      SHFileOp.pTo = "f:\"
      SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMMKDIR + FOF_NOCONFIRMATION
      Call SHFileOperation(SHFileOp)
    Next i
    temp_new = CDate(Now)
    temp_sub = CDate(temp_new - temp_old)
    temp_s = Second(temp_sub)
    temp_h = Hour(temp_sub)
    temp_m = Minute(temp_sub)
    temp_sum = temp_s + (temp_h * 3600) + (temp_m * 60)
    temp_a = 30
    temp_b = 1024
    temp_num1 = temp_a * temp_b
    temp_num2 = CInt(temp_num1 / temp_sum)MsgBox "ok"End SubPrivate Sub Timer1_Timer()
    Second = Second + 1
    If Second > 59 Then
    Minute = Minute + 1
    Second = 0
    If Minute > 59 Then
    Hour = Hour + 1
    Minute = 0
    Second = 0
    End If
    End SubPrivate Sub comstart_Click()
      Dim temp_old, temp_new, temp_sub As Date
      Dim temp_a As Long
      Dim temp_b As Long
      Dim bytedata() As Byte
      Dim numblocks As Long
      Dim filelength As Long
      Dim leftover As Long
      Dim sourcefile1, sourcefile2 As Long
      Dim i As Long
      Dim diskfile As String
      Dim offset As Long
      Dim temp As Boolean
      Dim temp_path As String
      Dim tmr As Single
      Dim temp_num1 As Long
      Dim temp_num2 As Long
      Dim temp_sum As Integer  sourcefile1 = FreeFile
      sourcefile2 = FreeFile + 1
      '1024.txt是一个文件大小为1M的文本文件
      Open "f:\1024.txt" For Binary Access Read As sourcefile1
      Open "c:\zjgl.txt" For Binary Access Write As sourcefile2
      ReDim bytedata(1 To LOF(sourcefile1))
      Get sourcefile1, , bytedata()
       For i = 1 To 30
            Put sourcefile2, , bytedata()
       Next i
      temp_new = CDate(Now)
      temp_sub = CDate(temp_new - temp_old)
      temp_s = Second(temp_sub)
      temp_h = Hour(temp_sub)
      temp_m = Minute(temp_sub)
      temp_sum = temp_s + (temp_h * 3600) + (temp_m * 60)
      Close sourcefile1
      Close sourcefile2
      temp_a = 30
      temp_b = 1024
      temp_num1 = temp_a * temp_b
      If temp_sum <> 1 Then
        temp_num2 = CInt(temp_num1 / temp_sum)
      End If
      MsgBox "ok"
     end sub
      

  9.   

    您看我这样的想法正确吗?  
     
    1.测试闪存盘的数据写入速度  
       从计算机硬盘上复制文件到闪存盘,计算总时间,进而得到闪存盘数据写入速度.是否此时,我也得到了计算机硬盘的数据读取速度.  
    2.测试闪存盘的数据读取速度  
       从闪存盘上复制文件到计算机硬盘,计算总时间,进而得到闪存盘的数据读取速度.是否此时,我也得到了计算机硬盘的数据写入速度.  
     
    测试闪存盘的数据写入速度,源程序如下(向闪存盘中写入一个30M大小的文件,每次写1M,分30次):  
     
    Private  Sub  comstart_Click()  
       Dim  temp_old,  temp_new,  temp_sub  As  Date  
       Dim  temp_a  As  Long  
       Dim  temp_b  As  Long  
       Dim  bytedata()  As  Byte  
       Dim  numblocks  As  Long  
       Dim  filelength  As  Long  
       Dim  leftover  As  Long  
       Dim  sourcefile1,  sourcefile2  As  Long  
       Dim  i  As  Long  
       Dim  diskfile  As  String  
       Dim  offset  As  Long  
       Dim  temp  As  Boolean  
       Dim  temp_path  As  String  
       Dim  tmr  As  Single  
       Dim  temp_num1  As  Long  
       Dim  temp_num2  As  Long  
       Dim  temp_sum  As  Integer  
     
       sourcefile1  =  FreeFile  
       sourcefile2  =  FreeFile  +  1  
       '1024.txt是一个文件大小为1M的文本文件  
       Open    "f:\1024.txt  "  For  Binary  Access  Read  As  sourcefile1  
       Open    "c:\zjgl.txt  "  For  Binary  Access  Write  As  sourcefile2  
       ReDim  bytedata(1  To  LOF(sourcefile1))  
       Get  sourcefile1,  ,  bytedata()  
         For  i  =  1  To  30  
                   Put  sourcefile2,  ,  bytedata()  
         Next  i  
       temp_new  =  CDate(Now)  
       temp_sub  =  CDate(temp_new  -  temp_old)  
       temp_s  =  Second(temp_sub)  
       temp_h  =  Hour(temp_sub)  
       temp_m  =  Minute(temp_sub)  
       temp_sum  =  temp_s  +  (temp_h  *  3600)  +  (temp_m  *  60)  
       Close  sourcefile1  
       Close  sourcefile2  
       temp_a  =  30  
       temp_b  =  1024  
       temp_num1  =  temp_a  *  temp_b  
       If  temp_sum    <  >  1  Then  
           temp_num2  =  CInt(temp_num1  /  temp_sum)  
       End  If  
       MsgBox    "ok  "  
     end  sub
      

  10.   

    晕死了,写得真麻烦,temp_new  =  CDate(Now)  计时也相当不准确