vb 计算时间间隔
来源:百度知道 编辑:UC知道 时间:2024/05/15 14:14:06
怎么用vb计算运行某个过程所消耗的时间 时间间隔要精确到毫秒或10毫秒
如计算1000次循环的耗时
用api函数 timegettime函数
Public Declare Function timeGetTime Lib "winmm.dll" Alias "timeGetTime" () As Long
例如
dim Stime as long
dim Etime as long
stime=timegettime()
你的程序段
etime=timegettime()
etime-stime'就是时间,单位为毫秒
没有这个timegettime函数
如计算1000次循环的耗时
用api函数 timegettime函数
Public Declare Function timeGetTime Lib "winmm.dll" Alias "timeGetTime" () As Long
例如
dim Stime as long
dim Etime as long
stime=timegettime()
你的程序段
etime=timegettime()
etime-stime'就是时间,单位为毫秒
没有这个timegettime函数
用api函数 timegettime函数
Public Declare Function timeGetTime Lib "winmm.dll" Alias "timeGetTime" () As Long
例如
dim Stime as long
dim Etime as long
stime=timegettime()
你的程序段
etime=timegettime()
etime-stime'就是时间,单位为毫秒
Dim time1 As integer,time2 as integer,time3 as integer
time1=timer'程序运行前的时间
.......’运行的程序
time2=timer'程序结束后的时间
time3=time2-time1’总时间
print time3’输出
最简单的
begin=timer()
for i=0 to 1000
next
end=timer()
msgbox end-begin