App::Benchmark - App::Benchmark documentation


App-Benchmark documentation Contained in the App-Benchmark distribution.

Index


Code Index:

VERSION

Top

version 1.102310

SYNOPSIS

Top

    # This is t/benchmark.t:

    use App::Benchmark;

    benchmark_diag(2_000_000, {
        sqrt => sub { sqrt(2) },
        log  => sub { log(2) },
    });

DESCRIPTION

Top

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.

Ricardo Signes came up with the idea.

FUNCTIONS

Top

benchmark_diag

Takes a number of iterations and a benchmark definition hash, just like timethese() from the 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 dummy test is being generated to keep the testing framework happy.

This function is exported automatically.

INSTALLATION

Top

See perlmodinstall for information and options on installing Perl modules.

BUGS AND LIMITATIONS

Top

No bugs have been reported.

Please report any bugs or feature requests through the web interface at http://rt.cpan.org.

AVAILABILITY

Top

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://search.cpan.org/dist/App-Benchmark/.

The development version lives at http://github.com/hanekomu/App-Benchmark/. Instead of sending patches, please fork this project using the standard git and github infrastructure.

AUTHOR

Top

Marcel Gruenauer <marcel@cpan.org>

COPYRIGHT AND LICENSE

Top


App-Benchmark documentation Contained in the App-Benchmark distribution.

use 5.008;
use strict;
use warnings;

package App::Benchmark;
BEGIN {
  $App::Benchmark::VERSION = '1.102310';
}
# ABSTRACT: Output your benchmarks as test diagnostics

use Test::More;
use Benchmark qw(cmpthese timethese :hireswallclock);
use Capture::Tiny qw(capture);
use Exporter qw(import);
our @EXPORT = ('benchmark_diag');

sub benchmark_diag {
    my ($iterations, $benchmark_hash) = @_;
    my $stdout = capture {
        cmpthese(timethese($iterations, $benchmark_hash));
    };
    diag $stdout;
    plan tests => 1;
    pass('benchmark');
}
1;


__END__