Redim computationally expensive?

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

    #1

    Redim computationally expensive?

    I have some 2-4D arrays that are filled by several different subs.
    Instead of maintaining a global or module level counter, I'd rather
    redim the array after each sub is finished, and start the next sub out
    at ubound(ary).

    The program is already getting sluggish and I'm looking for ways to
    improve performance--is redimming the arrays adding an unnecessary
    load?

    BTW, if anyone has some good ways to investigate which parts of the
    program are dragging it down, I'd appreciate any advice. I don't have
    a performance monitor.
    I'm using several data source/data consumer classes, but the
    performance doesn't degrade more as I add more of those (or add more
    datamembers to them), so I'm not sure if that's the problem.

    Thanks--
  • Steve Gerrard

    #2
    Re: Redim computationally expensive?


    "Kate" <kate@curio.com > wrote in message
    news:2cb4c040.0 401180709.41423 666@posting.goo gle.com...[color=blue]
    > I have some 2-4D arrays that are filled by several different subs.
    > Instead of maintaining a global or module level counter, I'd rather
    > redim the array after each sub is finished, and start the next sub out
    > at ubound(ary).
    >
    > The program is already getting sluggish and I'm looking for ways to
    > improve performance--is redimming the arrays adding an unnecessary
    > load?
    >
    > BTW, if anyone has some good ways to investigate which parts of the
    > program are dragging it down, I'd appreciate any advice. I don't have
    > a performance monitor.
    > I'm using several data source/data consumer classes, but the
    > performance doesn't degrade more as I add more of those (or add more
    > datamembers to them), so I'm not sure if that's the problem.
    >
    > Thanks--[/color]

    Redim-Preserve an array means allocating a new, bigger block of memory,
    copying the old block to the new block, and releasing the old block.
    Whether that is a performance hit depends on how big the array is, how
    much memory is available, and how the time involved compares to whatever
    else you are doing. Several larger redims are usually preferable to lots
    of smaller redims.

    If you are using data sources, you might want to see whether retrieving
    data is the main slow down, compared to array processing. It often is,
    since it is disk/network intensive. As far as how to monitor, start with
    a few Debug.Print "starting process X at " & Now and Debug.Print
    "finished process X at " & Now, and then look harder at the processes
    that take too long.

    We always enjoy seeing some code and offering opinions on which bits
    could be tweaked for performance...: )


    Comment

    • Kate

      #3
      Re: Redim computationally expensive?

      > > The program is already getting sluggish and I'm looking for ways to[color=blue][color=green]
      > > improve performance--is redimming the arrays adding an unnecessary
      > > load?
      > >
      > > BTW, if anyone has some good ways to investigate which parts of the
      > > program are dragging it down, I'd appreciate any advice.[/color][/color]
      [color=blue]
      > Redim-Preserve an array means allocating a new, bigger block of memory,
      > copying the old block to the new block, and releasing the old block.
      > Whether that is a performance hit depends on how big the array is, how
      > much memory is available, and how the time involved compares to whatever
      > else you are doing. Several larger redims are usually preferable to lots
      > of smaller redims.
      >
      > If you are using data sources, you might want to see whether retrieving
      > data is the main slow down, compared to array processing. It often is,
      > since it is disk/network intensive. As far as how to monitor, start with
      > a few Debug.Print "starting process X at " & Now and Debug.Print
      > "finished process X at " & Now, and then look harder at the processes
      > that take too long.
      >
      > We always enjoy seeing some code and offering opinions on which bits
      > could be tweaked for performance...: )[/color]
      Really? From reading other posts, I had the impression nobody could
      help me this way. How/to whom do I post it, and how should I
      discriminate about the relevant bits? See, here's the deal: I had a
      big messy program to clean up, and I learned a bit about component
      design and using VB data sources/consumers as I was fixing the
      program. So there is a bit of a mish-mash here (e.g., in one "half" of
      the program--the drawing half--I made complex-bound data consumer
      classes. In the second half, I dispensed with that and just used the
      sources, since it seemed a bit less unwieldy. Now I'm wondering which
      half might be in need of more tuning-up.)

      Comment

      • Larry Serflaten

        #4
        Re: Redim computationally expensive?

        "Kate" <kate@curio.com > wrote[color=blue]
        >[color=green]
        > > We always enjoy seeing some code and offering opinions on which bits
        > > could be tweaked for performance...: )[/color][/color]
        [color=blue]
        > Really? From reading other posts, I had the impression nobody could
        > help me this way. How/to whom do I post it, and how should I
        > discriminate about the relevant bits?[/color]

        Isolate the problemed code. Make a small demo that demonstrates the
        problems so that they can be reproduced on the systems of those who
        would offer help.

        Often times, while creating the demo, you can find the mistakes, or
        clean up the code, to eliminate the problems. If not, you still have a
        short demo you can post for others to try out.

        Very few are going to want to look at several forms, half a dozen modules
        and classes just to find a problem in one small area of a program. We
        often need to see the actual code that causes the problem, to know what
        the cause is, and especially to see where improvements might be offered.

        LFS




        -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
        http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
        -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

        Comment

        • J French

          #5
          Re: Redim computationally expensive?

          On 21 Jan 2004 05:44:21 -0800, kate@curio.com (Kate) wrote:

          <snip>
          [color=blue]
          >Really? From reading other posts, I had the impression nobody could
          >help me this way. How/to whom do I post it, and how should I
          >discriminate about the relevant bits? See, here's the deal: I had a
          >big messy program to clean up, and I learned a bit about component
          >design and using VB data sources/consumers as I was fixing the
          >program. So there is a bit of a mish-mash here (e.g., in one "half" of
          >the program--the drawing half--I made complex-bound data consumer
          >classes. In the second half, I dispensed with that and just used the
          >sources, since it seemed a bit less unwieldy. Now I'm wondering which
          >half might be in need of more tuning-up.)[/color]

          Your posts have been too vague for us to latch on to.

          However one general bit of advice seems appropriate
          - apply 'Occam's Razor'

          Remove and fake bits until you see things improving
          - collect data and then release a routine on a command button

          Repeat that for all small parts of the App

          When you find the bottleneck - post again
          - but the chances are you will not need to - it will be obvious

          Comment

          Working...