Skip to content

Instantly share code, notes, and snippets.

@tomill
Created November 10, 2010 17:08
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 tomill/671143 to your computer and use it in GitHub Desktop.
Save tomill/671143 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Benchmark;
my %a = (
foo => 1,
bar => 2,
baz => 3,
);
Benchmark::cmpthese(-1, {
'mr.doredd' => sub {
my %b;
@b{ values %a } = keys %a;
},
'reverse' => sub {
my %b;
%b = reverse %a;
},
});
Rate mr.doredd reverse
mr.doredd 255530/s -- -18%
reverse 312785/s 22% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment