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