Skip to content

Instantly share code, notes, and snippets.

@schwern
Created February 27, 2010 02:50
Show Gist options
  • Save schwern/316427 to your computer and use it in GitHub Desktop.
Save schwern/316427 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use strict;
use warnings;
use List::MoreUtils qw(uniq);
use Benchmark qw(cmpthese);
sub somni_uniq { my %seen; grep { !$seen{$_}++ } @_ }
my @array = (1..100, 2, 4, 29, 9240, 28, "foo", "baz");
cmpthese(shift || -3, {
moreutils => sub {
return uniq @array;
},
somni => sub {
return somni_uniq @array;
},
});
__END__
Rate somni moreutils
somni 11758/s -- -19%
moreutils 14541/s 24% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment