Create two public variables on your form (Dim sTime as long, eTime as long)
When the code starts .. sTime = Time()
When the code stops.. eTime = time()
Then stick the results of sTime-oTime in a text box..
First question is how precise do you want your timings to be? For example, using the built-in Time function will provide you resolutions to about 1/100 of a second. Using the GetTickCount API will get you into about the 55 millisecond range, and for even better timings, the QueryPerformanceCounter can get you into the 4-6 microsecond range.
That being said, the test the speed of various code snippets, you need to have a good test environment set up. Windows does lots of things in the background, such as buffer flushing, or other applications, such as Outlook, may periodically check for, or download mail. If any of these things happen while you running your timer tests, your results will be skewed. You also need to be aware of cacheing issues. You need to take every possible precaution to ensure that nothing can happen in the background while your testing, and then structure your code so that you timing exactly what you want to time. Also, run the tests many times and average the results.
Good Luck
-------------- As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.