- or download this
use Benchmark qw( cmpthese );
use List::Util qw( shuffle );
...
ref_h 139/s 140% 117% 6% -- -0% -6%
hash_r 140/s 141% 117% 6% 0% -- -5%
hash_h 147/s 155% 130% 12% 6% 6% --
- or download this
my @rand = ( map { int rand $range } 1 .. $ITERS )[0 .. $ITERS/2];
my @hits = ( shuffle keys %HASH )[0 .. $ITERS/2];
my @miss = ( grep { ! exists $HASH{$_} } 0 .. $range )[0 .. $ITERS/2];
- or download this
Rate ref_h hash_h ref_r ref_m hash_r hash_m
ref_h 229/s -- -10% -13% -18% -22% -30%
...
ref_m 279/s 22% 10% 6% -- -5% -14%
hash_r 295/s 29% 16% 12% 6% -- -10%
hash_m 326/s 42% 28% 24% 17% 11% --