467,207 Members | 1,309 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,207 developers. It's quick & easy.

VB.NET Very Slow

BK
I was writing an application VB.NET that inputs a TEXT file (about 5 MB).
The reading code took for ever (20+ minutes) to read in 120,000 Lines. I had
to quit coding in .NET and had to go back to VB6 to deliver the results.
Takes about 10 seconds with VB6. 99% identical code.

I must be doing something wrong. What is happening? My final trials were
ALL on my local disk - Application & Data.

Thanks.
Nov 21 '05 #1
  • viewed: 1359
Share:
6 Replies

"BK" <BK@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.com...
I was writing an application VB.NET that inputs a TEXT file (about 5 MB).
The reading code took for ever (20+ minutes) to read in 120,000 Lines. I
had
to quit coding in .NET and had to go back to VB6 to deliver the results.
Takes about 10 seconds with VB6. 99% identical code.

I must be doing something wrong. What is happening?


"99% identical code." is what's happening. VB.NET has very different
performance characteristics than VB6. Just because VB.NET supports much of
the same syntax for backwards compatibility, that doesn't mean that the
right way to code a particular program in VB6 and VB.NET is the same.

When you code things "the VB6 way" you may well not get very good
performance.

If you post a simple repro, someone may be able to suggest a better way to
do it in .NET.

David
Nov 21 '05 #2

"David Browne" <davidbaxterbrowne no potted me**@hotmail.com> wrote in
message news:uV*************@TK2MSFTNGP14.phx.gbl...

"BK" <BK@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.com...
I was writing an application VB.NET that inputs a TEXT file (about 5 MB).
The reading code took for ever (20+ minutes) to read in 120,000 Lines. I had
to quit coding in .NET and had to go back to VB6 to deliver the results.
Takes about 10 seconds with VB6. 99% identical code.

I must be doing something wrong. What is happening?
"99% identical code." is what's happening. VB.NET has very different
performance characteristics than VB6. Just because VB.NET supports much

of the same syntax for backwards compatibility, that doesn't mean that the
right way to code a particular program in VB6 and VB.NET is the same.

When you code things "the VB6 way" you may well not get very good
performance.

If you post a simple repro, someone may be able to suggest a better way to
do it in .NET.

David


In addition to David's comments...
Given your description, I bet you are using a bunch of Strings, correct?
Are you doing a lot of concatentating and other types of manipulation?
If so, this is most likely your problem. You will need to ditch the String's
in favor of StringBuilder.

In my experience, using Strings in the same manner as VB6 can result in HUGE
performance issues. But after rewriting the code to utilize StringBuilder I
found much code now runs measurably faster than VB6. When "upgrading" VB6
code, sadly there is quite a bit of rewriting required for similar reasons.

Gerald
Nov 21 '05 #3
I must concur. I had a little function that concatenated a series of
"numbers" into one big string - ie.: "0001 0004 2102 2394" etc. to send to
a database. Using string concatenation such as "a = a + b" was a gigantic
performance hit. Changed to StringBuilder and it now zips through tens of
thousands in a fraction of a second.

"Gerald Hernandez" <Cablewizard@sp*********@Yahoo.com> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl...

"David Browne" <davidbaxterbrowne no potted me**@hotmail.com> wrote in
message news:uV*************@TK2MSFTNGP14.phx.gbl...

"BK" <BK@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.com...
>I was writing an application VB.NET that inputs a TEXT file (about 5
>MB).
> The reading code took for ever (20+ minutes) to read in 120,000 Lines. I > had
> to quit coding in .NET and had to go back to VB6 to deliver the
> results.
> Takes about 10 seconds with VB6. 99% identical code.
>
> I must be doing something wrong. What is happening?


"99% identical code." is what's happening. VB.NET has very different
performance characteristics than VB6. Just because VB.NET supports much

of
the same syntax for backwards compatibility, that doesn't mean that the
right way to code a particular program in VB6 and VB.NET is the same.

When you code things "the VB6 way" you may well not get very good
performance.

If you post a simple repro, someone may be able to suggest a better way
to
do it in .NET.

David


In addition to David's comments...
Given your description, I bet you are using a bunch of Strings, correct?
Are you doing a lot of concatentating and other types of manipulation?
If so, this is most likely your problem. You will need to ditch the
String's
in favor of StringBuilder.

In my experience, using Strings in the same manner as VB6 can result in
HUGE
performance issues. But after rewriting the code to utilize StringBuilder
I
found much code now runs measurably faster than VB6. When "upgrading" VB6
code, sadly there is quite a bit of rewriting required for similar
reasons.

Gerald

Nov 21 '05 #4
"BK" <BK@discussions.microsoft.com> schrieb:
I was writing an application VB.NET that inputs a TEXT file (about 5 MB).
The reading code took for ever (20+ minutes) to read in 120,000 Lines. I
had
to quit coding in .NET and had to go back to VB6 to deliver the results.
Takes about 10 seconds with VB6. 99% identical code.

I must be doing something wrong. What is happening? My final trials were
ALL on my local disk - Application & Data.


I think you'll have to show us some code...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
Code?

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.
Nov 21 '05 #6
BK
I figured out the issues with some help. I was using legacy VB6 Code -
including Arrays, Redim Preserve and as you guys pointed out - string
comparisons and concatanations. However, it was the Array that was the
Killer. When I switched to ArrayList - I had comparable speeds with my VB6
program. Thanks for all your support.

Bobby.

"Dick Grier" wrote:
Code?

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by yawnmoth | last post: by
8 posts views Thread by Neil | last post: by
3 posts views Thread by Jennyfer J Barco | last post: by
50 posts views Thread by diffuser78@gmail.com | last post: by
reply views Thread by Pratchaya | last post: by
3 posts views Thread by John | last post: by
10 posts views Thread by penworthamnaynesh@googlemail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.