Benchmark 2 codes

E

Edo

Hello
I am not able to run these 2 codes to find which is faster because I
just don't know how to. any help is appriciated.

thanks

#!/perl -w
use strict;
use warnings;
use List::permutor;
use Algorithm::permute;
use Benchmark qw:)all);


my $perm = new List::permutor qw/ a b c d e /;
while (my @set = $perm->next) {
print "@set.\n";
}

my $p = new Algorithm::permute(['a'..'e']);
while (my @res = $p->next) {
print join(", ", @res), "\n";
}

cmpthese($count, {
'Name1' => '...code1...',
'Name2' => '...code2...',
});
 
U

Uri Guttman

E" == Edo said:
I am not able to run these 2 codes to find which is faster because I
just don't know how to. any help is appriciated.

my $perm = new List::permutor qw/ a b c d e /;
while (my @set = $perm->next) {
print "@set.\n";
}
my $p = new Algorithm::permute(['a'..'e']);
while (my @res = $p->next) {
print join(", ", @res), "\n";
}


wrap those two snippets in subs.
cmpthese($count, {
'Name1' => '...code1...',
'Name2' => '...code2...',

call the subs in the strings. choose better names (like the module names)

done.

uri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top