Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: map versus for

by jbert (Priest)
on Aug 05, 2008 at 10:48 UTC ( #702315=note: print w/replies, xml ) Need Help??

in reply to map versus for

You're right. I'm surprised too (not least because map could actually be implemented that way within perl...). I get a lot of variability (perl 5.8.8, x86_64-linux-gnu-thread-multi), but the for loop is a little faster.

All the comments about better style still stand, but I would certainly have expected the map to be faster. This is odd. Anyone have a 5.10 to hand to see if anything has changed?


# Populate list with 10 mio numbers for (my $i=0; $i<1000_000; $i++) { push @results, $i; }
is perhaps better written as: my @results = (0..1_000_000); (Of course, given your observation regarding map, whether it performs better is now a whole 'nother ball of wax.)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://702315]
[shmem]: some? are you jokin' ?
[shmem]: fuel is only one fuel that fuels the fools... it is all about power and control - which NOBODY will have.
[shmem]: ...can't have, since silly
[Discipulus]: yes. the central thing is the power. itself

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2017-04-29 22:07 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (534 votes). Check out past polls.