[Dbix-class] perl 5.10.0 and Class::Accessor::Grouped

Christopher H. Laco claco at chrislaco.com
Thu Dec 20 17:53:05 GMT 2007


> perl 5.10.0 compiled with configure.gnu (FreeBSD6.2, 3Ghz P4 prescott,
> DDR333).
> [root at lion] /home/syber =3D>./perl510/bin/perl test/cst.plx
> Benchmark: running seta, setao, setb, setbo for at least 1 CPU seconds...
>       seta:  1 wallclock secs ( 1.03 usr +  0.00 sys =3D  1.03 CPU) @
> 177939.39/s (n=3D183500)
>      setao:  1 wallclock secs ( 1.05 usr +  0.00 sys =3D  1.05 CPU) @
> 221411.34/s (n=3D231790)
>       setb:  1 wallclock secs ( 1.06 usr +  0.00 sys =3D  1.06 CPU) @
> 174841.41/s (n=3D185769)
>      setbo:  1 wallclock secs ( 0.99 usr +  0.01 sys =3D  1.00 CPU) @
> 220200.00/s (n=3D220200)



> perl 5.8.8 compiled with configure.gnu (the same machine)
> [root at lion] /home/syber =3D>./operl58/bin/perl test/cst.plx
> Benchmark: running seta, setao, setb, setbo for at least 1 CPU seconds...
>       seta:  1 wallclock secs ( 1.09 usr +  0.00 sys =3D  1.09 CPU) @
> 268435.20/s (n=3D293601)
>      setao:  1 wallclock secs ( 1.10 usr +  0.00 sys =3D  1.10 CPU) @
> 307535.89/s (n=3D338770)
>       setb:  1 wallclock secs ( 1.08 usr +  0.00 sys =3D  1.08 CPU) @
> 272325.57/s (n=3D293601)
>      setbo:  1 wallclock secs ( 1.12 usr +  0.00 sys =3D  1.12 CPU) @
> 303234.69/s (n=3D338770)


Now, the curious thing to me is that set_inherited is also slower, on
all 4 variations of blessed instance and non-blessed class.

set_inherited isn't nearly as complicated as get_inherited is:

> sub set_inherited {
>     my ($self, $set, $val) =3D @_;
> =

>     if (blessed $self) {
>         if (reftype $self eq 'HASH') {
>             return $self->{$set} =3D $val;
>         } else {
>             croak('Cannot set inherited value on an object instance that =
is not hash-based');
>         };
>     } else {
>         no strict 'refs';
> =

>         return ${$self.'::__cag_'.$set} =3D $val;
>     };
> }


So, to me, that almost points to blessed itself, which just sounds too
obvious. Could you benchmark just blessed() on each version?

What version of Scalar::Util do you have? Is it all possible it's a
non-compiled version?

What if you replace blessed $self with ref $self just for giggles?

/me scratches head...

-=3DChris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20071220/40=
3157b8/signature.pgp


More information about the DBIx-Class mailing list