VB.NET Very Slow

G

Guest

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.
 
D

David Browne

BK said:
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
 
G

Gerald Hernandez

David Browne said:
"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
 
S

Slow Learner

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.
 
H

Herfried K. Wagner [MVP]

BK said:
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...
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top