7 # This is a rather unusual test.
8 # It does not test any aspect of DBIx::Class, but instead tests the
9 # perl installation this is being run under to see if it is:-
10 # 1. Potentially affected by a RH perl build bug
11 # 2. If so we do a performance test for the effect of
14 # You can skip these tests by setting the DBIC_NO_WARN_BAD_PERL env
17 # If these tests fail then please read the section titled
18 # Perl Performance Issues on Red Hat Systems in
19 # L<DBIx::Class::Manual::Troubleshooting>
22 'Skipping RH perl performance bug tests as DBIC_NO_WARN_BAD_PERL set'
23 if ( $ENV{DBIC_NO_WARN_BAD_PERL} );
25 plan skip_all => 'Skipping as AUTOMATED_TESTING is set'
26 if ( $ENV{AUTOMATED_TESTING} );
28 eval "use Benchmark ':all'";
29 plan skip_all => 'needs Benchmark for testing' if $@;
33 ok( 1, 'Dummy - prevents next test timing out' );
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 >= 2
41 my $results = timethese(
42 -1, # run for 1 CPU second each
46 for ( my $i = 0 ; $i < 10000 ; $i++ ) {
50 bless_overload => sub {
51 use overload q(<) => sub { };
53 for ( my $i = 0 ; $i < 10000 ; $i++ ) {
54 $h{$i} = bless [] => 'main';
60 my $ratio = $results->{no_bless}->iters / $results->{bless_overload}->iters;
62 ok( ( $ratio < 2 ), 'Overload/bless performance acceptable' )
64 "This perl has a substantial slow down when handling large numbers\n",
65 "of blessed/overloaded objects. This can severely adversely affect\n",
66 "the performance of DBIx::Class programs. Please read the section\n",
67 "in the Troubleshooting POD documentation entitled\n",
68 "'Perl Performance Issues on Red Hat Systems'\n",
71 # We will only check for the difference in bless handling (whether the
72 # bless applies to the reference or the referent) if we have seen a
73 # performance issue...
76 skip "Not checking for bless handling as performance is OK", 1
80 package # don't want this in PAUSE
82 use overload bool => sub { 0 }
89 bless $r1 => 'TestRHBug';
93 sub _possibly_has_bad_overload_performance {
94 return $] < 5.008009 && !_has_bug_34925();
97 # If this next one fails then you almost certainly have a RH derived
98 # perl with the performance bug
99 # if this test fails, look at the section titled
100 # "Perl Performance Issues on Red Hat Systems" in
101 # L<DBIx::Class::Manual::Troubleshooting>
102 # Basically you may suffer severe performance issues when running
103 # DBIx::Class (and many other) modules. Look at getting a fixed
104 # version of the perl interpreter for your system.
106 ok( !_possibly_has_bad_overload_performance(),
107 'Checking whether bless applies to reference not object' )
109 "This perl is probably derived from a buggy Red Hat perl build\n",
110 "Please read the section in the Troubleshooting POD documentation\n",
111 "entitled 'Perl Performance Issues on Red Hat Systems'\n",