in reply to Perl array performance puzzle

Map will preallocate memory required for the array in a larger chunk than pushing into an array. It depends on how much real memory is assigned and allocated on your system and how fragmented it is. What does pre sizing the array for both map and push type builds do to your benchmark?

@a1= (); @a2= (); $#a1 = 1000000; $#a2 = 1000000;


-Waswas

Replies are listed 'Best First'.
Re^2: Perl array performance puzzle
by hardburn (Abbot) on Jul 30, 2004 at 16:27 UTC

    I would expect that to only change the time it takes to build the array, not to access an element.

    ----
    send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.