in reply to How to access a static hash.
output:use strict; use warnings; use Benchmark qw(cmpthese); cmpthese(-10, { 'anon' => sub { for my $x (qw(a b a b a b)) { my $y = { 'a' => 'A' +, 'b' => 'B'}->{$x}; }}, 'named' => sub { for my $x (qw(a b a b a b)) { my $h = { 'a' => 'A +', 'b' => 'B'}; my $y = $h->{$x}; }}, });
Meaning that using an anonymous (not stored) hash is just a bit faster. Not very interesting, considering you almost always want to reuse a hash you've just created.Rate named anon named 78120/s -- -8% anon 84539/s 8% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to access a static hash.
by gam3 (Curate) on Mar 17, 2007 at 20:33 UTC | |
by Joost (Canon) on Mar 17, 2007 at 21:00 UTC |