VB.NET Very Slow

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BK

    VB.NET Very Slow

    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.
  • David Browne

    #2
    Re: VB.NET Very Slow


    "BK" <BK@discussions .microsoft.com> wrote in message
    news:054954CE-A82F-4050-9DC5-381FCC40D443@mi crosoft.com...[color=blue]
    >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?[/color]

    "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


    Comment

    • Gerald Hernandez

      #3
      Re: VB.NET Very Slow


      "David Browne" <davidbaxterbro wne no potted meat@hotmail.co m> wrote in
      message news:uV3OBE0sFH A.284@TK2MSFTNG P14.phx.gbl...[color=blue]
      >
      > "BK" <BK@discussions .microsoft.com> wrote in message
      > news:054954CE-A82F-4050-9DC5-381FCC40D443@mi crosoft.com...[color=green]
      > >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.[/color][/color]
      I[color=blue][color=green]
      > > 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?[/color]
      >
      > "99% identical code." is what's happening. VB.NET has very different
      > performance characteristics than VB6. Just because VB.NET supports much[/color]
      of[color=blue]
      > 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
      >[/color]

      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


      Comment

      • Slow Learner

        #4
        Re: VB.NET Very Slow

        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 am_remove@Yahoo .com> wrote in message
        news:elrej60sFH A.3752@TK2MSFTN GP09.phx.gbl...[color=blue]
        >
        > "David Browne" <davidbaxterbro wne no potted meat@hotmail.co m> wrote in
        > message news:uV3OBE0sFH A.284@TK2MSFTNG P14.phx.gbl...[color=green]
        >>
        >> "BK" <BK@discussions .microsoft.com> wrote in message
        >> news:054954CE-A82F-4050-9DC5-381FCC40D443@mi crosoft.com...[color=darkred]
        >> >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.[/color][/color]
        > I[color=green][color=darkred]
        >> > 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?[/color]
        >>
        >> "99% identical code." is what's happening. VB.NET has very different
        >> performance characteristics than VB6. Just because VB.NET supports much[/color]
        > of[color=green]
        >> 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
        >>[/color]
        >
        > 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
        >
        >[/color]


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: VB.NET Very Slow

          "BK" <BK@discussions .microsoft.com> schrieb:[color=blue]
          >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.[/color]

          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/>

          Comment

          • Dick Grier

            #6
            Re: VB.NET Very Slow

            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.


            Comment

            • BK

              #7
              Re: VB.NET Very Slow

              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:
              [color=blue]
              > 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.
              >
              >
              >[/color]

              Comment

              Working...