Benchmark-Apps-0.04/000755 000765 000024 00000000000 11704606330 014315 5ustar00ambsstaff000000 000000 Benchmark-Apps-0.04/Changes000644 000765 000024 00000000673 11704606314 015620 0ustar00ambsstaff000000 000000 Revision history for Benchmark-Apps 0.04 January 15, 2012 - 17h28m - Release 0.04 that's in the source repository 0.03 August 30, 2008 - 21h20m - API change for flexibility. - Added support for different command arguments per iteration. 0.02 August 18, 2008 - 14h36m - Upload of version 0.01 failed. 0.01 August 16, 2008 - 14h26m - Added the basic code needed to run simple benchmarks. Benchmark-Apps-0.04/examples/000755 000765 000024 00000000000 11704606330 016133 5ustar00ambsstaff000000 000000 Benchmark-Apps-0.04/lib/000755 000765 000024 00000000000 11704606330 015063 5ustar00ambsstaff000000 000000 Benchmark-Apps-0.04/Makefile.PL000644 000765 000024 00000001011 11051404656 016262 0ustar00ambsstaff000000 000000 use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Benchmark::Apps', AUTHOR => 'Aberto Simoes ', VERSION_FROM => 'lib/Benchmark/Apps.pm', ABSTRACT_FROM => 'lib/Benchmark/Apps.pm', PL_FILES => {}, PREREQ_PM => { 'Time::HiRes' => '0', 'Test::More' => '0', }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Benchmark-Apps-*' }, ); Benchmark-Apps-0.04/MANIFEST000644 000765 000024 00000000434 11704606330 015447 0ustar00ambsstaff000000 000000 Changes MANIFEST Makefile.PL README lib/Benchmark/Apps.pm examples/sed_VS_perl t/00-load.t t/pod-coverage.t t/pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Benchmark-Apps-0.04/META.json000644 000765 000024 00000001624 11704606330 015741 0ustar00ambsstaff000000 000000 { "abstract" : "Simple interface to benchmark applications.", "author" : [ "Aberto Simoes " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.113640", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Benchmark-Apps", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "runtime" : { "requires" : { "Test::More" : 0, "Time::HiRes" : 0 } } }, "release_status" : "stable", "version" : "0.04" } Benchmark-Apps-0.04/META.yml000644 000765 000024 00000001012 11704606330 015560 0ustar00ambsstaff000000 000000 --- abstract: 'Simple interface to benchmark applications.' author: - 'Aberto Simoes ' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.113640' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Benchmark-Apps no_index: directory: - t - inc requires: Test::More: 0 Time::HiRes: 0 version: 0.04 Benchmark-Apps-0.04/README000644 000765 000024 00000001350 11051552535 015176 0ustar00ambsstaff000000 000000 Benchmark-Apps ---------------- Benchmark::Apps provides a simple interface to Benchmark external applications. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Benchmark::Apps You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Benchmark-Apps AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/Benchmark-Apps CPAN Ratings http://cpanratings.perl.org/d/Benchmark-Apps Search CPAN http://search.cpan.org/dist/Benchmark-Apps Benchmark-Apps-0.04/t/000755 000765 000024 00000000000 11704606330 014560 5ustar00ambsstaff000000 000000 Benchmark-Apps-0.04/t/00-load.t000644 000765 000024 00000000120 11051552415 016071 0ustar00ambsstaff000000 000000 #!perl -T use Test::More tests => 1; BEGIN { use_ok( 'Benchmark::Apps' ); } Benchmark-Apps-0.04/t/pod-coverage.t000644 000765 000024 00000001047 11051403333 017313 0ustar00ambsstaff000000 000000 use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok(); Benchmark-Apps-0.04/t/pod.t000644 000765 000024 00000000350 11051403333 015516 0ustar00ambsstaff000000 000000 #!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); Benchmark-Apps-0.04/lib/Benchmark/000755 000765 000024 00000000000 11704606330 016755 5ustar00ambsstaff000000 000000 Benchmark-Apps-0.04/lib/Benchmark/Apps.pm000644 000765 000024 00000012302 11704606247 020223 0ustar00ambsstaff000000 000000 package Benchmark::Apps; use warnings; use strict; use Time::HiRes qw.gettimeofday tv_interval.; =head1 NAME Benchmark::Apps - Simple interface to benchmark applications. =cut our $VERSION = '0.04'; =head1 SYNOPSIS This module provides a simple interface to benchmark applications (not necessarily Perl applications). use Benchmark::Apps; my $commands = { cmd1 => 'run_command_1 with arguments', cmd2 => 'run_command_2 with other arguments', }; my $conf = { pretty_print=>1, iters=>5 }; Benchmark:Apps::run( $commands, $conf ); =head1 DESCRIPTION This module can be used to perform simple benchmarks on programs. Basically, it can be used to benchmark any program that can be called with a system call. =head1 FUNCTIONS =head2 run This method is used to run benchmarks. It runs the commands described in the hash passed as argument. It returns an hash of the results each command. A second hash reference can be passed to this method: a configuration hash reference. The values passed in this hash override the default behaviour of the run method. The configuration options available at this moment are: =over 4 =item C When enabled it will print to stdout, in a formatted way the results of the benchmarks as they finish running. This option should de used when you want to run benchmarks and want to see the results progress as the tests run. You can disable it, so you can perform automated benchmarks. Options: true (1) or false (0) Default: false (0) =item C This is the number of iterations that each test will run. Options: integer greater than 1 Default: 5 =item C This is a reference to an anonymous function that will calculate the command argument based on the iteraction number. Options: any function reference that returns a string Default: empty function: always returns an empty string, which means no arguments will be given to the command =back =head2 run This method runs the commands described in the hash passed as argument. It returns an hash of the results and return codes for each command. =cut sub _empty { '' } my %cfg = ( pretty_print => 1, iters => 5 , args => \&_empty ); my %command = (); my %res = (); sub run { my @args = @_; @args == 0 and die 'At least one hash reference needs to be passed as argument'; @args > 2 and die 'A maximum of two arguments (hash refs) should be passed to this function'; # in case we got the second argument (configuration hash ref) if (@args > 1) { if (ref $args[1] eq 'HASH') { my @l = keys %{$args[1]}; foreach (@l) { if (defined $args[1]{$_}) { # XXX and validate args $cfg{$_} = $args[1]{$_}; } } } else { warn 'Second argument to run should be an hash ref'; } } %command = %{$args[0]}; for my $iter (1..$cfg{'iters'}) { for my $c (keys %command) { $res{$c}{'run'} = $command{$c}; my $time = time_this($command{$c}.' '.&{$cfg{'args'}}($iter)); $res{$c}{'result'}{$iter} = $time; } } pretty_print(%res) if $cfg{'pretty_print'}; return +{%res}; } sub _validate_option { my ($option, $value) = @_; # TODO do some validations # everything ok for now return 1; } =head2 pretty_print This method is used to print the final result to STDOUT before returning from the C method. =cut sub pretty_print { my $self = shift; for my $iter (1..$cfg{'iters'}) { _show_iter($iter); for my $c (keys %command) { printf " %8s => %8.4f s\n", $c, $res{$c}{'result'}{$iter}; } } } sub _show_iter { my $i = shift; printf "%d%s iteration:\n", $i, $i==1?"st":$i==2?"nd":$i==3?"rd":"th"; } =head2 time_this This method is not meant to be used directly, although it can be useful. It receives a command line and executes it via system, taking care of registering the elapsed time. =cut sub time_this { my $cmd_line = shift; my $start_time = [gettimeofday]; system("$cmd_line 2>&1 > /dev/null"); return tv_interval($start_time); } =head1 EXAMPLES Check files in C. =head1 AUTHOR Aberto Simoes (aka ambs), C<< >> Nuno Carvalho (aka smash), C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Benchmark::Apps You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 COPYRIGHT & LICENSE Copyright 2008 Aberto Simoes, Nuno Carvalho, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut !!1; # End of Benchmark::Apps __END__ Benchmark-Apps-0.04/examples/sed_VS_perl000644 000765 000024 00000000433 11057550613 020266 0ustar00ambsstaff000000 000000 #!/usr/bin/perl use warnings; use strict; use lib qw( . lib ../lib ); use Benchmark::Apps; my $commands = { sed=> 'echo "1 22 333 4444" | sed -e "s/[1-9]\+/N/g"', perl=> 'echo "1 22 333 4444" | perl -p -e "s/[1-9]+/N/g;"', }; my $results = Benchmark::Apps::run($commands);