1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
9 delete $ENV{DBIC_ASSERT_NO_ERRONEOUS_METAINSTANCE_USE};
12 'Skipping RH perl performance bug tests as DBIC_NO_WARN_BAD_PERL set'
13 if ( $ENV{DBIC_NO_WARN_BAD_PERL} );
15 require DBICTest::RunMode;
16 plan skip_all => 'Skipping as system appears to be a smoker'
17 if DBICTest::RunMode->is_smoker;
20 # globalllock so that the test runs alone
21 use DBICTest ':GlobalLock';
25 # This is a rather unusual test.
26 # It does not test any aspect of DBIx::Class, but instead tests the
27 # perl installation this is being run under to see if it is:-
28 # 1. Potentially affected by a RH perl build bug
29 # 2. If so we do a performance test for the effect of
32 # You can skip these tests by setting the DBIC_NO_WARN_BAD_PERL env
35 # If these tests fail then please read the section titled
36 # Perl Performance Issues on Red Hat Systems in
37 # L<DBIx::Class::Manual::Troubleshooting>
39 # we do a benchmark test filling an array with blessed/overloaded references,
40 # against an array filled with array refs.
41 # On a sane system the ratio between these operation sets is 1 - 1.5,
42 # whereas a bugged system gives a ratio of around 8
43 # we therefore consider there to be a problem if the ratio is >= $fail_ratio
46 ok( $fail_ratio, "Testing for a blessed overload slowdown >= ${fail_ratio}x" );
49 my $results = timethese(
50 -1, # run for 1 WALL second each
54 for ( my $i = 0 ; $i < 10000 ; $i++ ) {
58 bless_overload => sub {
59 use overload q(<) => sub { };
61 for ( my $i = 0 ; $i < 10000 ; $i++ ) {
62 $h{$i} = bless [] => 'main';
68 my $ratio = $results->{no_bless}->iters / $results->{bless_overload}->iters;
70 cmp_ok( $ratio, '<', $fail_ratio, 'Overload/bless performance acceptable' )
73 "This perl has a substantial slow down when handling large numbers\n",
74 "of blessed/overloaded objects. This can severely adversely affect\n",
75 "the performance of DBIx::Class programs. Please read the section\n",
76 "in the Troubleshooting POD documentation entitled\n",
77 "'Perl Performance Issues on Red Hat Systems'\n",
78 "As this is an extremely serious condition, the only way to skip\n",
79 "over this test is to --force the installation, or to look in the test\n",
80 "file " . __FILE__ . "\n",
83 # We will only check for the difference in bless handling (whether the
84 # bless applies to the reference or the referent) if we have seen a
85 # performance issue...
88 skip "Not checking for bless handling as performance is OK", 1
89 if Test::Builder->new->is_passing;
92 package # don't want this in PAUSE
94 use overload bool => sub { 0 }
101 bless $r1 => 'TestRHBug';
105 sub _possibly_has_bad_overload_performance {
106 return( "$]" < 5.008009 and !_has_bug_34925() );
109 # If this next one fails then you almost certainly have a RH derived
110 # perl with the performance bug
111 # if this test fails, look at the section titled
112 # "Perl Performance Issues on Red Hat Systems" in
113 # L<DBIx::Class::Manual::Troubleshooting>
114 # Basically you may suffer severe performance issues when running
115 # DBIx::Class (and many other) modules. Look at getting a fixed
116 # version of the perl interpreter for your system.
118 ok( !_possibly_has_bad_overload_performance(),
119 'Checking whether bless applies to reference not object' )
122 "This perl is probably derived from a buggy Red Hat perl build\n",
123 "Please read the section in the Troubleshooting POD documentation\n",
124 "entitled 'Perl Performance Issues on Red Hat Systems'\n",
125 "As this is an extremely serious condition, the only way to skip\n",
126 "over this test is to --force the installation, or to look in the test\n",
127 "file " . __FILE__ . "\n",