Seems to be the case that named hash lookups are (marginally, but consistently) quicker:
{ my $ref = { 1 .. 1e6 }; my %h = 1 .. 1e6; cmpthese -5,{ a => sub{ exists $ref->{$_} and 1 for 1 .. 1e6; }, b => sub{ exists $h{$_} and 1 for 1 .. 1e6; } } };; Rate a b a 1.24/s -- -3% b 1.28/s 3% -- Rate a b a 1.36/s -- -5% b 1.43/s 5% -- Rate a b a 1.24/s -- -3% b 1.28/s 3% -- Rate a b a 1.23/s -- -5% b 1.29/s 5% -- Rate a b a 1.27/s -- -3% b 1.30/s 3% --
In reply to Re^3: Faster Hash Slices
by BrowserUk
in thread Faster Hash Slices
by jht
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |