Created
May 13, 2015 09:25
-
-
Save bioinfornatics/d25f9ff0ae639f60f864 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/env perl | |
use strict; | |
use warnings; | |
use 5.010; | |
use List::MoreUtils qw(uniq); | |
#use Data::Dumper::Names; | |
use Benchmark qw(:all) ; | |
sub test1 { | |
my @tab = (["12","25","2","18","9","25","18","30","30","12","30","30","18","12"],["154","12","56","8","22","88","74","12","56","32","88","88","56","12","12","56"]); | |
foreach my $row (@tab) { | |
@$row = uniq @$row; | |
} | |
} | |
sub test2 { | |
my @tab = (["12","25","2","18","9","25","18","30","30","12","30","30","18","12"],["154","12","56","8","22","88","74","12","56","32","88","88","56","12","12","56"]); | |
for(my $i=0;$i<=$#tab;$i++) | |
{ | |
my $ref=$tab[$i]; | |
my %values= map {$_ => 1 } @$ref; | |
$tab[$i]=[keys(%values)]; | |
} | |
} | |
timethese(1000000, {'test1' => \&test1, 'test2' => \&test2} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment