Skip to content

Instantly share code, notes, and snippets.

@kentfredric
Created September 9, 2009 09:41
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 kentfredric/183614 to your computer and use it in GitHub Desktop.
Save kentfredric/183614 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use MooseX::Declare;
use lib '.';
use TestCase;
my $tc = TestCase->new();
$tc->example;
#!/usr/bin/perl
use strict;
use warnings;
use MooseX::Declare;
use lib '.';
use TestCase2;
my $tc = TestCase2->new();
$tc->example;
make coverage
$WEBBROWSER cover_db/TestCase-pm.html
make profile
$WEBBROWSER nytprof/index.html
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
#!/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];
}
}
}
#!/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];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment