Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lang/perl/App-Benchmark: initial import.
git-svn-id: http://svn.coderepos.org/share/lang/perl/App-Benchmark/trunk@22597 d0d07461-0603-4401-acd4-de1884942a52
- Loading branch information
Marcel Gruenauer
committed
Nov 2, 2008
1 parent
2eaa236
commit 9fb517f
Showing
12 changed files
with
304 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
steps = FindVersion, ChangeVersion, CheckChangeLog, Manifest, DistTest, Commit, Tag, MakeDist, MyUploadCPAN, DistClean, Twitter | ||
|
||
svn.tagpattern = http://svn.coderepos.org/share/lang/perl/App-Benchmark/tags/App-Benchmark-%v | ||
|
||
twitter.config = ~/.twitterrc | ||
twitter.distname = App-Benchmark | ||
twitter.message = shipped %d %v - soon at %u | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Revision history for Perl extension App-Benchmark | ||
|
||
0.01 2008-11-02T21:31:53Z (Marcel Gruenauer <marcel@cpan.org>) | ||
- original version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Changes | ||
inc/Module/AutoInstall.pm | ||
inc/Module/Install.pm | ||
inc/Module/Install/AutoInstall.pm | ||
inc/Module/Install/Base.pm | ||
inc/Module/Install/Can.pm | ||
inc/Module/Install/Fetch.pm | ||
inc/Module/Install/Include.pm | ||
inc/Module/Install/Makefile.pm | ||
inc/Module/Install/Metadata.pm | ||
inc/Module/Install/Win32.pm | ||
inc/Module/Install/WriteAll.pm | ||
inc/Test/Compile.pm | ||
inc/Test/More.pm | ||
lib/App/Benchmark.pm | ||
Makefile.PL | ||
MANIFEST This list of files | ||
META.yml | ||
README | ||
t/00_compile.t | ||
t/00_perl_critic.t | ||
t/00_pod.t | ||
t/benchmark.t | ||
t/perlcriticrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Version control files and dirs. | ||
\bRCS\b | ||
\bCVS\b | ||
.svn | ||
,v$ | ||
|
||
# Makemaker/Build.PL generated files and dirs. | ||
^MANIFEST\. | ||
^Makefile$ | ||
^Build$ | ||
^blib/ | ||
^pm_to_blib/ | ||
^_build/ | ||
^MakeMaker-\d | ||
embedded/ | ||
cover_db/ | ||
smoke.html | ||
smoke.yaml | ||
smoketee.txt | ||
sqlnet.log | ||
BUILD.SKIP | ||
COVER.SKIP | ||
CPAN.SKIP | ||
t/000_standard__* | ||
|
||
# Temp, old, emacs, vim, backup files. | ||
~$ | ||
\.old$ | ||
\.swp$ | ||
\.tar$ | ||
\.tar\.gz$ | ||
^#.*#$ | ||
^\.# | ||
.shipit | ||
|
||
# Local files, not to be included | ||
^scratch/ | ||
core | ||
^var/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use inc::Module::Install; | ||
include 'Module::AutoInstall'; | ||
|
||
name 'App-Benchmark'; | ||
all_from 'lib/App/Benchmark.pm'; | ||
perl_version '5.006'; | ||
|
||
requires 'Benchmark'; | ||
requires 'IO::Capture::Stdout'; | ||
|
||
recommends 'Test::Pod'; | ||
recommends 'Test::Pod::Coverage'; | ||
|
||
test_requires 'Test::More' => '0.70'; | ||
test_requires 'Test::Compile'; | ||
|
||
auto_install; | ||
auto_include; | ||
WriteAll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
This is the Perl distribution App-Benchmark. | ||
|
||
INSTALLATION | ||
|
||
App-Benchmark installation is straightforward. If your CPAN shell is | ||
set up, you should just be able to do | ||
|
||
% cpan App::Benchmark | ||
|
||
Download it, unpack it, then build it as per the usual: | ||
|
||
% perl Makefile.PL | ||
% make && make test | ||
|
||
Then install it: | ||
|
||
% make install | ||
|
||
DOCUMENTATION | ||
|
||
App-Benchmark documentation is available as in POD. So you can do: | ||
|
||
% perldoc App::Benchmark | ||
|
||
to read the documentation online with your favorite pager. | ||
|
||
Marcel Gruenauer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package App::Benchmark; | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use Benchmark qw(cmpthese timethese :hireswallclock); | ||
use IO::Capture::Stdout; | ||
|
||
|
||
our $VERSION = '0.01'; | ||
|
||
|
||
use base 'Exporter'; | ||
|
||
|
||
our %EXPORT_TAGS = ( | ||
util => [ qw/benchmark_diag/ ], | ||
); | ||
|
||
our @EXPORT_OK = @{ $EXPORT_TAGS{all} = [ map { @$_ } values %EXPORT_TAGS ] }; | ||
|
||
|
||
sub benchmark_diag { | ||
my ($iterations, $benchmark_hash) = @_; | ||
my $capture = IO::Capture::Stdout->new; | ||
|
||
$capture->start; | ||
cmpthese(timethese($iterations, $benchmark_hash)); | ||
$capture->stop; | ||
|
||
print "# $_" for $capture->read; | ||
plan tests => 1; | ||
pass('benchmark'); | ||
} | ||
|
||
|
||
1; | ||
|
||
|
||
__END__ | ||
=head1 NAME | ||
App::Benchmark - Output your benchmarks as test diagnostics | ||
=head1 SYNOPSIS | ||
# This is t/benchmark.t: | ||
use App::Benchmark ':all'; | ||
benchmark_diag(2_000_000, { | ||
sqrt => sub { sqrt(2) }, | ||
log => sub { log(2) }, | ||
}); | ||
=head1 DESCRIPTION | ||
This module makes it easy to run your benchmarks in a distribution's test | ||
suite. This way you just have to look at the CPAN testers reports to see your | ||
benchmarks being run on many different platforms using many different versions | ||
of perl. | ||
=head1 EXPORTS | ||
Nothing is exported automatically. The function can be exported using its name | ||
or the C<:all> tag. | ||
=over 4 | ||
=item benchmark_diag | ||
Takes a number of iterations and a benchmark definition hash, just like | ||
C<timethese()> from the L<Benchmark> module. Runs the benchmarks and reports | ||
them, each line prefixed by a hash sign so it doesn't mess up the TAP output. | ||
Also, a pseudotest is being generated to keep the testing framework happy. | ||
=back | ||
=head1 BUGS AND LIMITATIONS | ||
No bugs have been reported. | ||
Please report any bugs or feature requests through the web interface at | ||
L<http://rt.cpan.org>. | ||
=head1 INSTALLATION | ||
See perlmodinstall for information and options on installing Perl modules. | ||
=head1 AVAILABILITY | ||
The latest version of this module is available from the Comprehensive Perl | ||
Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN | ||
site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>. | ||
=head1 AUTHORS | ||
Marcel GrE<uuml>nauer, C<< <marcel@cpan.org> >> | ||
=head1 COPYRIGHT AND LICENSE | ||
Copyright 2008 by Marcel GrE<uuml>nauer | ||
This library is free software; you can redistribute it and/or modify | ||
it under the same terms as Perl itself. | ||
=cut | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!perl -w | ||
|
||
use strict; | ||
use warnings; | ||
|
||
BEGIN { | ||
use Test::More; | ||
eval "use Test::Compile"; | ||
Test::More->builder->BAIL_OUT( | ||
"Test::Compile required for testing compilation") if $@; | ||
all_pm_files_ok(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!perl -w | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use FindBin '$Bin'; | ||
use File::Spec; | ||
use UNIVERSAL::require; | ||
use Test::More; | ||
|
||
plan skip_all => | ||
'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.' | ||
unless $ENV{TEST_AUTHOR}; | ||
|
||
my %opt; | ||
my $rc_file = File::Spec->catfile($Bin, 'perlcriticrc'); | ||
$opt{'-profile'} = $rc_file if -r $rc_file; | ||
|
||
if (Perl::Critic->require('1.078') && | ||
Test::Perl::Critic->require && | ||
Test::Perl::Critic->import(%opt)) { | ||
|
||
all_critic_ok("lib"); | ||
} else { | ||
plan skip_all => $@; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!perl -w | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
eval "use Test::Pod"; | ||
plan skip_all => "Test::Pod required for testing POD" if $@; | ||
all_pod_files_ok(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env perl | ||
|
||
use warnings; | ||
use strict; | ||
use App::Benchmark ':all'; | ||
|
||
benchmark_diag(2_000_000, { | ||
sqrt => sub { sqrt(2) }, | ||
log => sub { log(2) }, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# no strict 'refs' | ||
[TestingAndDebugging::ProhibitNoStrict] | ||
allow = refs | ||
|
||
[-BuiltinFunctions::ProhibitStringyEval] | ||
[-ControlStructures::ProhibitMutatingListFunctions] | ||
[-Subroutines::ProhibitExplicitReturnUndef] | ||
[-Subroutines::ProhibitSubroutinePrototypes] | ||
[-Variables::ProhibitConditionalDeclarations] | ||
|
||
# for mkdir $dir, 0777 | ||
[-ValuesAndExpressions::ProhibitLeadingZeros] |