This little Perl Benchmark shows that its better to iterate through an array as to manipulate via shift.For more about shift look at Perl array pop, push, shift, unshift.
1 2 3 4 5 6 7 8 9 10 |
#!/usr/bin/perl use strict; use warnings; use Benchmark qw(:all) ; cmpthese(-1, { 'shift' => sub {my @var = (1..4);print shift(@var); }, 'iterate' => sub {my @var = (1..4);print $var[0]; }, }); |
We see its better to iterate as to shift from an array:
1 2 |
shift 1147836/s -- -4% iterate 1191563/s 4% -- |
Outstanding post however , I was wanting to know if you could write
a litte more on this topic? I’d be very thankful if you could elaborate a
little bit further. Kudos!
It’s impressive that you are getting ideas from this article as well as from our discussion made here.
For most recent information you have to pay a quick visit world-wide-web and on the web I found this website as
a most excellent website for hottest updates.