Basic BenchMarking
Since we're going to be looking at both COM and API methods of doing similar tasks, it will be useful to be able to do some quantitative comparisons of the methods. The simplest way to achieve this is to time execution of methods that perform identical tasks.
For timing, LVTutorial uses the GetTickCount API which simply returns the number of milliseconds since the device was last started. The number is a Long and therefore the chance of wrapping back to zero occurs about 50 days after startup. This precision and reliability make it a great tool for execution timing.
To time the execution of a method, you simply store the return value of GetTickCount before execution and then subtract that value from the return value of GetTickCount after execution.
The execution time of COMPopulate is calculated in the Click event handler for cmdCOM.
On my iPaq 3650 I get times of around 60 milliseconds.
Private Sub cmdCOM_Click()
Dim lTime As Long
' get current tick count
lTime = GetTickCount
' populate the listview using object model methods
COMPopulate
' determine ET and display it
lblET.Caption = CStr(GetTickCount - lTime)
End Sub