Skip to content

Instantly share code, notes, and snippets.

@nihen
Created December 12, 2011 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nihen/1465943 to your computer and use it in GitHub Desktop.
Save nihen/1465943 to your computer and use it in GitHub Desktop.
use Benchmark qw/cmpthese/;
my $hash = +{
id => 123,
mail => 'chiba@everqueue.com',
};
my @keys = qw/id mail/;
cmpthese(-1, {
slice => sub {
join ', ', @$hash{@keys};
},
map => sub {
join ', ', map { $hash->{$_} } @keys;
},
});
==============================
Rate map slice
map 771011/s -- -60%
slice 1927529/s 150% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment