Search code examples
stringvb6profilingtimer

How to get time elapsed in milliseconds


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?


Solution

  • Yes, you can use the Win32 API:

    DWORD WINAPI GetTickCount(void);
    

    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.