Class::Axelerator - Evade OO taxes


Class-Axelerator documentation  | view source Contained in the Class-Axelerator distribution.

Index


VERSION

Top

$Id: Axelerator.pm,v 0.2 2009/02/15 02:25:03 dankogai Exp dankogai $

SYNOPSIS

Top

  my $obj = Klass->new(name => 'anon');
  use Class::Axelerator;
  $obj->name eq 'anon' or die;   # $obj->{name} ...
  $obj->name() eq 'anon' or die; # $obj->name() ...; no change
  $obj->pass = 'ymous';          # $obj->{pass} = ....
  no Class::Axelerator;

DESCRIPTION

Top

Perl's object orientation (POO as follows) is powerful, flexible and ... expensive. Since all methods are implemented as function calls, even simple accessors are 2-4 times more costly than non OO approach. Simply put,

  my $attr = $obj->attr;

is 2-4x costlier than

  my $attr = $obj->{attr};

This module axelerates the code by replacing all occurance of ->whatever with ->{whatever}, while ->whatever() remains intact.

Since the blessed hash reference is the de-facto POO standard, this accelerates most cases. This is true for Class::Accessor and its friends and even Moose and its family.

Whenever you want to call the method, just append ().

It is recommended that you end the section to axelerate with no Class::Axelerator. This module is NOT LEXICAL and its effect spans till the end of source without it.

BENCHMARK

Top

Here is a result of simple benchmark on my MacBook Pro. See t/benchmark.pl.

Accessor
                 Rate     normal axelerated
  normal     1035642/s         --       -78%
  axelerated 4797439/s       363%         --

Mutator
                  Rate     normal axelerated
  normal      920425/s         --       -80%
  axelerated 4691781/s       410%         --

Lvalue Mutator
                  Rate     normal axelerated
  normal     1281574/s         --       -72%
  axelerated 4637948/s       262%         --

Axelerate?

Top

It comes naturally since this module accelerates accessors/mutators by axing encapslulation.

EXPORT

Top

None. This is a source filter module.

AUTHOR

Top

Dan Kogai, <dankogai at dan.co.jp>

BUGS

Top

Tax evasion is considered felony in most countries and territories :)

Even in the Programming Republic of Perl, it is considered a bad practice.

Please report any bugs or feature requests to bug-class-axelerator at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-Axelerator. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Class::Axelerator




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-Axelerator

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Class-Axelerator

* CPAN Ratings

http://cpanratings.perl.org/d/Class-Axelerator

* Search CPAN

http://search.cpan.org/dist/Class-Axelerator/

ACKNOWLEDGEMENTS

Top

Proof of concept http://blog.livedoor.jp/dankogai/archives/51077786.html

COPYRIGHT & LICENSE

Top


Class-Axelerator documentation  | view source Contained in the Class-Axelerator distribution.