plan skip_all => ".pmc are only available with 5.6 and later" if $] < 5.006;
-my $no_pmc = defined &Config::non_bincompat_options
- ? (grep $_ eq 'PERL_DISABLE_PMC', Config::non_bincompat_options())
- : ($Config::Config{ccflags} =~ /-DPERL_DISABLE_PMC\b/);
-plan skip_all => ".pmc are disabled in this perl"
- if $no_pmc;
+# Skip this test if perl is compiled with PERL_DISABLE_PMC
+#
+my $pmc = 1;
+if (Config->can('non_bincompat_options')) { # $] ge '5.014'
+ $pmc = 0
+ if grep { $_ eq 'PERL_DISABLE_PMC' } Config::non_bincompat_options();
+} elsif (eval {
+ require Config::Perl::V;
+ Config::Perl::V->VERSION('0.10');
+}) {
+ $pmc = 0
+ if Config::Perl::V::myconfig()->{options}{PERL_DISABLE_PMC};
+} else {
+ $pmc = 0
+ if $Config::Config{ccflags} =~ /(?:^|\s)-DPERL_DISABLE_PMC\b/;
+}
+
+plan skip_all => 'Perl is built with PERL_DISABLE_PMC' unless $pmc;
+
plan tests => 3;
use vars qw($got_here);
--- /dev/null
+#!perl -w\r
+use strict;\r
+use Benchmark qw/cmpthese/;\r
+use Test::More tests => 1;\r
+\r
+{\r
+ package Bench::Base;\r
+ sub foo { 1 };\r
+}\r
+\r
+my $c;\r
+my $sub_iter = 100;\r
+\r
+cmpthese (-1 => {\r
+ recompute_existing_ISA => sub {\r
+ $c++;\r
+ for (1..$sub_iter) {\r
+ my $class = "Bench::Par::Sub_${c}";\r
+ no strict 'refs';\r
+ @{ "$class\::ISA"} = (@{ "$class\::ISA"},'Bench::Base');\r
+ die unless $class->foo;\r
+ }\r
+ },\r
+ recompute_new_ISA => sub {\r
+ $c++;\r
+ for (1..$sub_iter) {\r
+ my $class = "Bench::Par::Sub_${c}::SubSub${_}";\r
+ no strict 'refs';\r
+ @{ "$class\::ISA"} = (@{ "$class\::ISA"},'Bench::Base');\r
+ die unless $class->foo;\r
+ }\r
+ },\r
+ push_existing_ISA => sub {\r
+ $c++;\r
+ for (1..$sub_iter) {\r
+ my $class = "Bench::Par::Sub_${c}";\r
+ no strict 'refs';\r
+ push @{ "$class\::ISA"}, 'Bench::Base';\r
+ die unless $class->foo;\r
+ }\r
+ },\r
+ push_new_ISA => sub {\r
+ $c++;\r
+ for (1..$sub_iter) {\r
+ my $class = "Bench::Par::Sub_${c}::SubSub${_}";\r
+ no strict 'refs';\r
+ push @{ "$class\::ISA"}, 'Bench::Base';\r
+ die unless $class->foo;\r
+ }\r
+ },\r
+ push_new_FOO => sub {\r
+ $c++;\r
+ for (1..$sub_iter) {\r
+ my $class = "Bench::Par::Sub_${c}::SubSub${_}";\r
+ no strict 'refs';\r
+ push @{ "$class\::FOO"}, 'Bench::Base';\r
+ #die unless $class->foo;\r
+ }\r
+ },\r
+ push_existing_FOO => sub {\r
+ $c++;\r
+ for (1..$sub_iter) {\r
+ my $class = "Bench::Par::Sub_${c}";\r
+ no strict 'refs';\r
+ push @{ "$class\::FOO"}, 'Bench::Base';\r
+ #die unless $class->foo;\r
+ }\r
+ },\r
+ recompute_existing_FOO => sub {\r
+ $c++;\r
+ for (1..$sub_iter) {\r
+ my $class = "Bench::Par::Sub_${c}";\r
+ no strict 'refs';\r
+ @{ "$class\::FOO"} = (@{ "$class\::FOO"}, 'Bench::Base');\r
+ #die unless $class->foo;\r
+ }\r
+ },\r
+ \r
+ # Take a reference and manipulate that, in case string references are slow\r
+ refcompute_existing_FOO => sub {\r
+ $c++;\r
+ for (1..$sub_iter) {\r
+ my $class = "Bench::Par::Sub_${c}";\r
+ no strict 'refs';\r
+ my $aref = \@{ "$class\::FOO"};\r
+ @{ $aref } = (@{ $aref }, 'Bench::Base');\r
+ #die unless $class->foo;\r
+ }\r
+ },\r
+ recompute_new_FOO => sub {\r
+ $c++;\r
+ for (1..$sub_iter) {\r
+ my $class = "Bench::Par::Sub_${c}::SubSub${_}";\r
+ no strict 'refs';\r
+ @{ "$class\::FOO"} = (@{ "$class\::FOO"}, 'Bench::Base');\r
+ #die unless $class->foo;\r
+ }\r
+ },\r
+});\r
+\r
+pass "Benchmarks run";\r