|
-
May 22nd, 2002, 03:32 AM
#1
Thread Starter
New Member
Win32 API calls
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
-
May 22nd, 2002, 08:25 AM
#2
the framework provides its own way of Getting Ticks...using API involves interop services which use more overhead
I think the .net way is System.GetTicks...or something like that..I cant remember although Ive answered this a couple time ..Try searching the forum for it.
-
May 23rd, 2002, 02:29 AM
#3
Thread Starter
New Member
Thanks!
The function is located at System.Environment.TickCount.
So it seem to be a overhead time of 500% (Interop) percent calling a API function instead of a framework function.
A call to the .NET framework is 25% slower than a similiar call from VB 6 to the Win 32 API.
OK, this seem to be a fact.
Last edited by Alfven; May 23rd, 2002 at 02:49 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|