BEGIN {
plan
skip_all
=>
'Skipping RH perl performance bug tests as DBIC_NO_WARN_BAD_PERL set'
if
(
$ENV
{DBIC_NO_WARN_BAD_PERL} );
plan
skip_all
=>
'Skipping as system appears to be a smoker'
if
DBICTest::RunMode->is_smoker;
}
my
$fail_ratio
= 3;
ok(
$fail_ratio
,
"Testing for a blessed overload slowdown >= ${fail_ratio}x"
);
my
$results
= timethese(
-1,
{
no_bless
=>
sub
{
my
%h
;
for
(
my
$i
= 0 ;
$i
< 10000 ;
$i
++ ) {
$h
{
$i
} = [];
}
},
bless_overload
=>
sub
{
my
%h
;
for
(
my
$i
= 0 ;
$i
< 10000 ;
$i
++ ) {
$h
{
$i
} =
bless
[] =>
'main'
;
}
},
},
);
my
$ratio
=
$results
->{no_bless}->iters /
$results
->{bless_overload}->iters;
cmp_ok(
$ratio
,
'<'
,
$fail_ratio
,
'Overload/bless performance acceptable'
)
|| diag(
"\n"
,
"This perl has a substantial slow down when handling large numbers\n"
,
"of blessed/overloaded objects. This can severely adversely affect\n"
,
"the performance of DBIx::Class programs. Please read the section\n"
,
"in the Troubleshooting POD documentation entitled\n"
,
"'Perl Performance Issues on Red Hat Systems'\n"
,
"As this is an extremely serious condition, the only way to skip\n"
,
"over this test is to --force the installation, or to look in the test\n"
,
"file "
. __FILE__ .
"\n"
,
);
SKIP: {
skip
"Not checking for bless handling as performance is OK"
, 1
if
Test::Builder->new->is_passing;
{
package
TestRHBug;
}
sub
_has_bug_34925 {
my
%thing
;
my
$r1
= \
%thing
;
my
$r2
= \
%thing
;
bless
$r1
=>
'TestRHBug'
;
return
!!
$r2
;
}
sub
_possibly_has_bad_overload_performance {
return
$] < 5.008009 && !_has_bug_34925();
}
ok( !_possibly_has_bad_overload_performance(),
'Checking whether bless applies to reference not object'
)
|| diag(
"\n"
,
"This perl is probably derived from a buggy Red Hat perl build\n"
,
"Please read the section in the Troubleshooting POD documentation\n"
,
"entitled 'Perl Performance Issues on Red Hat Systems'\n"
,
"As this is an extremely serious condition, the only way to skip\n"
,
"over this test is to --force the installation, or to look in the test\n"
,
"file "
. __FILE__ .
"\n"
,
);
}
done_testing;