Benchmarking Using Performance Counters

Benoit Frigon

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
This module allows you to do precise timing of your codes segments. It can be useful if you want to compare the perormances of two programming techniques. To use it, simply call the StartTiming before and StopTiming after the segment of your program you want to measure and read the results by calling ReadCodeTiming function.

This module removes the time required to call the timing function itself, so you get an even more accurate reading. It can return 4 type of units : Seconds, milliSeconds, microseconds and beats(the smallest unit).

This is not 100% accurate, you should always perform more than one test before you conclude anything. You can measure only one segment at a time.

It uses the QueryPerformanceCounter and QueryPerformanceFrequency apis to do the timing measurements. this method is far more precise than using the GetTickCount api(which I used myself before I discovered performance counters).

Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.