Rate hash if hash 9329/s -- -11% if 10473/s 12% -- Rate hash if hash 9436/s -- -11% if 10599/s 12% -- Rate hash if hash 9341/s -- -12% if 10662/s 14% -- #### use strict; use warnings; use Benchmark qw( cmpthese ); use constant INNER => $ARGV[0] || 10000; use constant OUTER => $ARGV[1] || -3; my $hash = <<'__EOI__'; use strict; use warnings; my @x = our @data; my %c; while (@x) { my $i = shift(@x); my $j = shift(@x); ++$c{"$i$j"}; } __EOI__ my $if = <<'__EOI__'; use strict; use warnings; my @x = our @data; my ($c00, $c01, $c10, $c11); while (@x) { my $i = shift(@x); my $j = shift(@x); if ($i) { if ($j) { $c11++; } else { $c10++; } } else { if ($j) { $c01++; } else { $c00++; } } } __EOI__ our @data = map chr('' . int(rand(2))), 1..INNER; cmpthese(OUTER, { 'hash' => $hash, 'if' => $if, });