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