Well, I'm honor-bound to reply that your seeming algorithmic superiority is directly attributable to your pernicious use of bitwise operations. You also have a subtle precedence bug in evilgrep that is fixed in the code below, and invalidates all your results. Furthermore, all your benchmarks are belong to me:
use Benchmark qw(cmpthese);
my @list = (0..100);
cmpthese (-3, {
c_style => sub { for (my $i = 0; $i <= $#list; $i += 2) {$list[$i]
+= 'h1' } },
slice => sub { $_ = 'h2' for @list[map {$_ << 1} 0..$#list/2] },
modulo => sub { $_ & 1 or $list[$_] = 'h3' for 0..$#list },
doubler => sub { $list[$_ << 1] = 'h4' for 0..@list/2 },
evilgrep => sub { @list[grep{!($_&1)}0..$#list]= ('h5')x @list },
grep => sub { @list[grep{!($_&1)}0..$#list]= ('h6')x(@list/2 + 1
+) }
});
### RESULTS ###
evilgrep 7467/s -- -19% -40% -42% -43% -65%
grep 9244/s 24% -- -25% -28% -30% -57%
c_style 12398/s 66% 34% -- -3% -6% -42%
modulo 12811/s 72% 39% 3% -- -3% -40%
slice 13211/s 77% 43% 7% 3% -- -38%
doubler 21289/s 185% 130% 72% 66% 61% --
ps. My system is currently underclocked, not to mention having slow timings, 4-way interleaving, and CAS2 disabled. If and when I reboot and tweak, I welcome you to bring it! :P
pps. Assuming of course, my computer boots up...
MeowChow
s aamecha.s a..a\u$&owag.print | [reply] [d/l] |
| [reply] |