Skip to content

Instantly share code, notes, and snippets.

@bioinfornatics
Created May 13, 2015 09:25
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 bioinfornatics/d25f9ff0ae639f60f864 to your computer and use it in GitHub Desktop.
Save bioinfornatics/d25f9ff0ae639f60f864 to your computer and use it in GitHub Desktop.
#!/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