more useful options | |
PerlMonks |
Re^5: How Perl can push array into array and then how retrieve [Benchmark]by kcott (Archbishop) |
on Dec 02, 2021 at 08:14 UTC ( [id://11139306]=note: print w/replies, xml ) | Need Help?? |
G'day cavac, "Your solution is probably a lot faster, ..." I've always found for to be faster than map so I benchmarked. I ran the following with: 0 .. 5 (from the two nodes on which you commented); 0 .. 40 (the OP's original range); and, 0 .. 5000 (just to see if a large range made any significant different).
I ran each three times; there was little difference in the results; I've just posted the middle results below.
The smallest difference was -21% vs. 27%; the largest was -25% vs. 33%. As the range was increased, all values tended towards -23% vs. 30% (the middle values for all runs). In this instance, for is faster than map (i.e. what I've always found in the past). — Ken
In Section
Seekers of Perl Wisdom
|
|