Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
18
Task/Time-a-function/Perl/time-a-function-1.pl
Normal file
18
Task/Time-a-function/Perl/time-a-function-1.pl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use Benchmark;
|
||||
use Memoize;
|
||||
|
||||
sub fac1 {
|
||||
my $n = shift;
|
||||
return $n == 0 ? 1 : $n * fac1($n - 1);
|
||||
}
|
||||
sub fac2 {
|
||||
my $n = shift;
|
||||
return $n == 0 ? 1 : $n * fac2($n - 1);
|
||||
}
|
||||
memoize('fac2');
|
||||
|
||||
my $result = timethese(100000, {
|
||||
'fac1' => sub { fac1(50) },
|
||||
'fac2' => sub { fac2(50) },
|
||||
});
|
||||
Benchmark::cmpthese($result);
|
||||
Loading…
Add table
Add a link
Reference in a new issue