Created
February 27, 2010 02:50
-
-
Save schwern/316427 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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