in reply to Array How to/Performance: mass initialization or update using array slice

Thank you for the extra explanation.

Still, which one is faster, looping or slicing for mass update? Thank you.
  • Comment on Re: Array How to/Performance: mass initialization or update using array slice

Replies are listed 'Best First'.
Re^2: Array How to/Performance
by Aristotle (Chancellor) on Jun 21, 2003 at 12:35 UTC
    Do you have a performance problem confirmed in a profiler at that point in your program? No? Then it doesn't matter.

    Makeshifts last the longest.

      But... isn't it good to know the fastest way for future reference? And... isn't tuning a good pedalogical tool for understanding Perl internals?

      -Tats

        "Pedalogical"? If you mean pathological - then yes. :) If you mean pegagogical, then so-so with a grain of maybe.

        This being as "micro" an optimization as it is, it is not likely you will be able to say it will be faster than something else in any particular case. If you can do more work than initializing the array in a loop, then using the slice method to fill it up front may possibly end up being slightly slower, f.ex. In any case this is not going to make a significant difference. The bottom line is that either way you turn it, you'll have to benchmark it for your data and your algorithm.

        Makeshifts last the longest.