all groups > dotnet interop > september 2004 >
You're in the

dotnet interop

group:

Speed : The PIA impact (VB 6.0 vs VB.NET)


Speed : The PIA impact (VB 6.0 vs VB.NET) Philippe TEIRUH
9/27/2004 9:45:05 AM
dotnet interop:
Hello,

I have made a migration from VB 6.0 to VB.NET and noticed a great speed
change when I access (from VB) to Excel Cells (same problem to write Visio
formulas from VB).
The same code takes 21 seconds in VB 6.0 and 54 seconds in VB.NET (see below)

1. Is that fact well known?
2. How to solve the problem?
3. Can we expect change in latter version?

---------------------------------------------------------

In VB 6.0 the following code is executed in 21 seconds in VB 6.0 and 54
seconds in VB.NET on the same PC:


Dim I As Integer
Dim J As Integer
Dim myExcelApp As Excel.Application
Dim objBook As Excel.Workbook
Dim objSheet As Excel.Worksheet
Dim dStart As Double

Set myExcelApp = CreateObject("Excel.Application")
Set objBook = myExcelApp.Workbooks.Add("D:\toto.xls")
Set objSheet = objBook.Worksheets("Sheet1")

dStart = Timer

For I = 1 To 60
For J = 1 To 100
objSheet.Cells(J, I).Value = 1
Next J
Next I
MsgBox ("This operation took : " & CStr(CInt(Timer - dStart)) & "
seconds")

--------------------------------------------------------------------------------------

Thank you

Philippe

PS : To make yourself the experience on VB.NET, just replace in this VB 6.0
code "Timer" by "Microsoft.VisualBasic.Timer"
Re: Speed : The PIA impact (VB 6.0 vs VB.NET) Mattias Sjögren
9/27/2004 11:21:42 PM
Philippe,

[quoted text, click to view]

Well all managed<->native transitions cause some overhead.


[quoted text, click to view]

Keep the loop code in native code (VB6) and call it from VB.NET.


[quoted text, click to view]

I doubt it.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
AddThis Social Bookmark Button