From: Yuval Kogman Date: Wed, 28 Jun 2006 13:52:26 +0000 (+0000) Subject: add an easy benchmark harness X-Git-Tag: 0_33~32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6698ebe5496d8d334573318c2282c6e11444e4fc;p=gitmo%2FClass-MOP.git add an easy benchmark harness --- diff --git a/bench/all.yml b/bench/all.yml new file mode 100644 index 0000000..093a833 --- /dev/null +++ b/bench/all.yml @@ -0,0 +1,11 @@ +--- +- name: Construction of Point classes + classes: + - 'MOP::Point' + - 'Plain::Point' + benchmarks: + - class: 'Bench::Construct' + args: + x: 7 + y: 137 + diff --git a/bench/lib/Bench/Run.pm b/bench/lib/Bench/Run.pm index dffb121..fc2009f 100644 --- a/bench/lib/Bench/Run.pm +++ b/bench/lib/Bench/Run.pm @@ -27,13 +27,18 @@ sub run { my $self = shift; foreach my $bench ( $self->benchmarks ) { - my ( $bench_class, @bench_args ) = @$bench; + my $bench_class = $bench->{class}; + my @bench_args = ( (ref($bench->{args}) eq "ARRAY") ? @{ $bench->{args} } : %{ $bench->{args} } ); + eval "require $bench_class"; die $@ if $@; + my %res; + foreach my $class ( $self->classes ) { eval "require $class"; die $@ if $@; + my $b = $bench_class->new( @bench_args, class => $class ); $res{$class} = countit( $self->min_time, $b->code ); } diff --git a/bench/run_yml.pl b/bench/run_yml.pl new file mode 100644 index 0000000..409de84 --- /dev/null +++ b/bench/run_yml.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/lib"; + +use YAML::Syck; +use Bench::Run; + +my $data = LoadFile( shift || "$FindBin::Bin/all.yml" ); + +foreach my $bench ( @$data ) { + print delete $bench->{name}, "\n"; + Bench::Run->new( %$bench )->run; +} + +