Class::XSAccessor::Compat
Moose
Mouse
+ Mousse
+ Moo
/) {
eval "require $_" or push @missing, $_;
}
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');
{
package $gen_class;
use $class;
has $meth => (is => 'rw');
-__PACKAGE__->meta->make_immutable;
+# some moosey thingies can not do this
+eval { __PACKAGE__->meta->make_immutable };
EOC
$bench_objs->{$name} = $gen_class->new;
sub _add_task {
my ($tasks, $name, $meth, $slot) = @_;
- $tasks->{$name} = eval "sub {
- for (my \$i = 0; \$i < 100; \$i++) {
- \$bench_objs->{$slot}->$meth(1);
- \$bench_objs->{$slot}->$meth(\$bench_objs->{$slot}->$meth + 1);
- }
- }";
+ # 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 } " or die $@;
}
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');
}
my $moose_based = {
moOse => 'Moose',
- ($ENV{MOUSE_PUREPERL} ? 'moUse' : 'moUse_XS') => 'Mouse',
+ moo_XS => 'Moo',
+ moUse_XS => 'Mouse',
+ moUse => 'Mousse',
};
for (keys %$moose_based) {
_add_moose_task ($tasks, $_, $moose_based->{$_})
}
+{
+ no warnings 'once';
+ local $Method::Generate::Accessor::CAN_HAZ_XS = 0;
+ _add_moose_task ($tasks, moo => 'Moo');
+}
-for (1, 2) {
+for (1 .. 5) {
print "Perl $], take $_:\n";
cmpthese ( -1, $tasks );
print "\n";