From: Peter Rabbitson Date: Thu, 16 Dec 2010 09:41:30 +0000 (+0000) Subject: Add an extra benchmark point - the inherited accessor type X-Git-Tag: v0.10002~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FClass-Accessor-Grouped.git;a=commitdiff_plain;h=52e8510128cc086282b490d5845cc89765348910 Add an extra benchmark point - the inherited accessor type --- diff --git a/benchmark/accessors b/benchmark/accessors index d5affd3..0e6cc7f 100644 --- a/benchmark/accessors +++ b/benchmark/accessors @@ -43,6 +43,10 @@ use Benchmark qw/:hireswallclock cmpthese/; local $Class::Accessor::Grouped::USE_XS = 1; __PACKAGE__->mk_group_accessors ('simple', 'cag_xs'); } + + __PACKAGE__->mk_group_accessors ('inherited', 'cag_inh'); + __PACKAGE__->cag_inh('initial value'); + __PACKAGE__->mk_accessors('caf'); { @@ -86,15 +90,19 @@ EOC sub _add_task { my ($tasks, $name, $meth, $slot) = @_; + # we precompile the desired amount of loops so that the loop itself + # does not get in the way with some sort of optimization or whatnot + my $perl; for (1 .. 1000) { $perl .= " + \$::init_val = \$bench_objs->{$slot}->$meth; \$bench_objs->{$slot}->$meth($_); \$bench_objs->{$slot}->$meth(\$bench_objs->{$slot}->$meth + $_); "; } - $tasks->{$name} = eval "sub { $perl } "; + $tasks->{$name} = eval "sub { $perl } " or die $@; } my $tasks = { @@ -104,7 +112,7 @@ my $tasks = { # } }; -for (qw/CAG CAG_XS CAF CAF_XS CAF_XSA XSA HANDMADE/) { +for (qw/CAG CAG_XS CAG_INH CAF CAF_XS CAF_XSA XSA HANDMADE/) { _add_task ($tasks, $_, lc($_), 'base'); }