Click to See Complete Forum and Search --> : Win32API calls


Alfven
May 22nd, 2002, 03:19 AM
Hello!
Following code take twice the time in VB .NET than in VB6. The large number of loop is there because otherwise it isīnt possible to meassure the time.

This was a simple task, but it seems to be the same trouble with OCX components created in C++. I tried to switch of the stack trace but this seem to put even more time to the call.

Is it the RCW that takes time?
Or is there any other problems?
I mean a ordinary loop is much faster in .NET than VB 6.

Private Sub TickBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TickBtn.Click

Dim StartTime As Double
Dim EndTime As Double
Dim i As Integer
Dim answer As Double

StartTime = GetTickCount
For i = 0 To 100000
test = GetTickCount()
Next
EndTime = GetTickCount
answer = EndTime - StartTime
TimeLbl.Text = answer / 1000
End Sub

'Other module
Module Global
'<SecurityPermission(SecurityAction.Assert, _
'Flags:=SecurityPermissionFlag.UnmanagedCode)> _
Declare Auto Function GetTickCount Lib "kernel32" () As Integer
End Module