如何以毫秒为单位获取时间 [英] How to get time elapsed in milliseconds
本文介绍了如何以毫秒为单位获取时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于字符串连接的性能在 VB6 中非常弱,我正在测试几个 StringBuilder 实现.要查看它们运行了多长时间,我目前使用内置的
Since performance of string concatenation is quite weak in VB6 I'm testing several StringBuilder implementations. To see how long they're running, I currently use the built-in
Timer
函数,它只给我午夜后经过的秒数.
function which only gives me the number of seconds that have passed after midnight.
有没有办法(我猜是通过导入系统函数)来获得毫秒精度的东西?
Is there a way (I guess by importing a system function) to get something with milliseconds precision?
推荐答案
是的,你可以使用 Win32 API:
Yes, you can use the Win32 API:
DWORD WINAPI GetTickCount(void);
要在 VB6 中导入它,像这样声明它:
To import it in VB6 declare it like this:
Private Declare Function GetTickCount Lib "kernel32" () As Long
在操作之前和之后调用它,然后计算经过的时间差.
Call it before the operation and after and then calculate the difference in time passed.
这篇关于如何以毫秒为单位获取时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文