如何计算一个算法的执行时间,要到毫秒级

解决方案 »

  1.   

    不用吧  Dim sngTimer As Single
      sngTimer = Timer  DoYourAlgorithmic  msgbox Timer - sngTimer
      

  2.   

    使用API:TIMEGETTIME
    Private Declare Function timeGetTime Lib "winmm.dll" () As Long
    sub anything()
    dim I as long
    I=timegettime
    ...    '中间你的处理过程
    ...
    Msgbox "用时:" & timegettime-I & "毫秒"
    end sub
      

  3.   

    sub subname()
    dim t1 as double
    dim t2 as doublet1=timer
    for i=1 to 10000
        .
        .
    next
    t2=timermsgbox round(t2-t1,3)
    end sub
      

  4.   

    Dim sngTimer As Single
      sngTimer = Timer  DoYourAlgorithmic  msgbox Timer - sngTimer
      

  5.   

    我写过这样的代码:是用JAVA,但思路都一样,如下:
    1、记录下要运行测试代码的时间startTime
    2、运行测试代码段
    3、记录下运行测试代码结束时间endTime
    4、测试代码运行时间excuteTime=endTime-startTime
    用不到Timer控件。
      

  6.   

    毫秒级别最好用GetTickCount,
    非常之精确!
    用法也是两次获取后相减!
      

  7.   

    Dim dtime As double
      dtime = Timer  call yoursub
      msgbox Timer - dtime 
      

  8.   

    api:
    gettickcount or getsystime
      

  9.   

    GetTickCount,没得说了,都让别人说了。
      

  10.   

    呵呵,我都是在自己的程序里面用自己代码做的
    用个Timer控件就能精确到毫秒级别!
      

  11.   

    Private Declare Function GetTickCount Lib "kernel32" () As LongPrivate Sub Command1_Click()
    Dim a, b, i As Long
    a = GetTickCount()
    b = 0
    For i = 0 To 99999999
    b = b + 1
    Next
    a = GetTickCount() - a
    Label1.Caption = "累加" + Str(b) + "次所耗费的时间:" + Str(a) + "毫秒"End Sub
    --------------------------------------------------------------------------
    以上是测试vb计算1亿次+1的程序,自己看吧,很简单
      

  12.   

    http://community.csdn.net/Expert/topic/2961/2961033.xml?temp=.6965906