What is the best way to synchronize / measure performance in VB6?

If I just want to quickly measure how long a particular function takes, what can I name to get the exact time? Given that the VB6 synchronization functions are not highly accurate, are there any Windows API functions that you call instead?

What other ways do you measure application performance? Are there any third-party tools you recommend?

+4
source share
3 answers

I usually use hihg performance counters for Windows. Check QueryPerformanceCounter and QueryPerfomanceFrequency

Usually I have a simple class whose constructor and destructor call QueryPerformanceCounter and then add the difference to the total.

For tools, check out the devpartner . Despite the fact that it works well, tools for significant parts of the code make my application run unbearably slow. Usually I find that I want to get the exact time for only one or two functions, so I often use the performance counter functions and do not use devpartner.

+4
source

I use high-performance multimedia timers. Here is a fragment debug profiling library.

Private Declare Function timeGetTime Lib "winmm.dll" () As Long Private Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long Private Declare Function timeEndPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long Private mlTimeStarted As Long Public Sub StartTimer(Optional lPeriod As Long = 1) 10 Call timeBeginPeriod(lPeriod) 20 mlTimeStarted = timeGetTime() End Sub Public Function GetTimeElapsed() As Long 10 GetTimeElapsed = timeGetTime() - mlTimeStarted End Function Public Sub EndTimer(Optional lPeriod As Long = 1) Debug.Assert lPeriod < 10 10 Call timeEndPeriod(lPeriod) 20 mlTimeStarted = 0 End Sub Public Sub DebugProfileStop() 10 Call EndTimer End Sub Public Sub DebugProfileReset() 10 If mlTimeStarted > 0 Then 20 EndTimer 30 End If 40 Call StartTimer End Sub Public Sub DebugProfile(sText As String) 10 Debug.Print "Debug " & sText & " : " & CStr(GetTimeElapsed) End Sub 

Using:

  DebugProfileReset DebugProfile("Before Loop") For index = 0 to 10000 DebugProfile("Before Call To Foo") Foo DebugProfile("Before Call To Bar") Bar DebugProfile("Before Call To Baz") Baz Next index DebugProfile("After Loop") DebugProfileStop 
+4
source

VB Watch is another tool you might want to consider.

These things are most universal when you can isolate suspicious areas of your code. Many tools of this type make it possible to limit the coverage of code tools to modules or individual procedures, or to limit monitoring to a procedure rather than an operator level. This can help reduce some of the pain associated with the linear equipment of the entire program.

+1
source

All Articles