如何计算一个算法的执行时间,要到毫秒级
解决方案 »
- 在EXCEL中调用用户函数
- 散分!
- 放向角问题
- 怎样删除注册表?急。。。急。。。100分
- 怎样在模块中访问UserControl中的元素?
- 请问高手怎么屏蔽Flash控件的右键菜单???
- 问:用ADO无DSN连SQLSERVER怎么导出EXCEL文件(要最方便的方法),给出SQL语句我马上就试,试通过了马上给分,谢谢大家
- MS Graph Control
- vs.net 是否必须在win2000 server 英文版下安装运行(sp1)
- 如何用VB在access数据库中搜索内容?
- 进来看看~(独家)~~~实现半透明窗体、不规则窗体、窗体置顶、拖动无标题栏窗体的ActiveX.dll(帮忙顶有分)
- 在类中自定义类型可以是public吗?
sngTimer = Timer DoYourAlgorithmic msgbox Timer - sngTimer
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
sub anything()
dim I as long
I=timegettime
... '中间你的处理过程
...
Msgbox "用时:" & timegettime-I & "毫秒"
end sub
dim t1 as double
dim t2 as doublet1=timer
for i=1 to 10000
.
.
next
t2=timermsgbox round(t2-t1,3)
end sub
sngTimer = Timer DoYourAlgorithmic msgbox Timer - sngTimer
1、记录下要运行测试代码的时间startTime
2、运行测试代码段
3、记录下运行测试代码结束时间endTime
4、测试代码运行时间excuteTime=endTime-startTime
用不到Timer控件。
非常之精确!
用法也是两次获取后相减!
dtime = Timer call yoursub
msgbox Timer - dtime
gettickcount or getsystime
用个Timer控件就能精确到毫秒级别!
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的程序,自己看吧,很简单