in reply to Re: Re: Re: Re: Generating an array of n identical elements
in thread Generating an array of n identical elements

my @new = map { transform $_ } @old; is faster than
my @new; push @new, transform $_ for @old;
I'm wary of your results though. My gut feeling is that something is getting optimized away at compile time, but I can't seem to get it deparsed like that. Maybe x is really 168x faster than map in this case (and in your perl build and on your machine)..

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^5: Generating an array of n identical elements
by bronto (Priest) on Sep 16, 2002 at 14:26 UTC
    something is getting optimized away at compile time

    Maybe it is due to the fact that Blake's was a real subroutine with parameters and mine is more like a <code>constant<code>...

    I expected a wider difference in my test case. Of course, Blake's is far more general than mine and it's results are much more reliable.

    Ciao!
    --bronto

    # Another Perl edition of a song:
    # The End, by The Beatles
    END {
      $you->take($love) eq $you->made($love) ;
    }