kentfredric (owner)

Revisions

gist: 183614 Download_button fork
public
Public Clone URL: git://gist.github.com/183614.git
Embed All Files: show embed
e.t #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl
 
use strict;
use warnings;
 
use MooseX::Declare;
use lib '.';
 
use TestCase;
 
my $tc = TestCase->new();
 
$tc->example;
 
 
 
e2.t #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/perl
 
use strict;
use warnings;
 
use MooseX::Declare;
use lib '.';
 
use TestCase2;
 
my $tc = TestCase2->new();
 
$tc->example;
 
INSTRUCTIONS #
1
2
3
4
5
6
7
make coverage
$WEBBROWSER cover_db/TestCase-pm.html
 
make profile
$WEBBROWSER nytprof/index.html
 
 
Makefile #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
coverage:
perl -MDevel::Cover -I. e.t
cover --summary
profile:
perl -d:NYTProf -I. e.t
nytprofhtml
 
clean-coverage:
rm -fr cover_db
 
clean-profile:
rm -fr nytprof.out
rm -fr nytprof
 
clean: clean-profile clean-coverage
 
TestCase.pm #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl
 
use strict;
use warnings;
 
use MooseX::Declare;
 
class TestCase {
 
method example {
# Quick Fibonacci impl.
my @list = ( 1 , 1 );
for ( 1 .. 1000 ){
push @list, $list[-1] + $list[-2];
}
}
method example_b {
# Quick Fibonacci impl.
my @list = ( 1 , 1 );
for ( 1 .. 1000 ){
push @list, $list[-1] + $list[-2];
}
}
 
}
 
TestCase2.pm #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
 
use strict;
use warnings;
 
use MooseX::Declare;
 
class TestCase2 {
use Benchmark;
 
method example {
# Quick Fibonacci impl.
my @list = ( 1 , 1 );
my @blist = ();
timethis(-2,sub {
for ( 1 .. 1000 ){
push @list, $list[-1] + $list[-2];
}
for ( 0.. $#list - 1 ){
push @blist, $list[$_]/$list[$_+1];
}});
}
method example_b {
# Quick Fibonacci impl.
my @list = ( 1 , 1 );
for ( 1 .. 1000 ){
push @list, $list[-1] + $list[-2];
}
}
 
}