in reply to Re^13: The Most Essential Perl Development Tools Today (negative)
in thread The Most Essential Perl Development Tools Today
then the subroutine probably has almost no code in it at all, and the solution is to inline the tiny amount of code in the subroutine and remove the calling overhead entirely.
Sure, you could do that, but are you really going to allow all the callers of your objects to access their attributes directly rather than going through getters?
Little bits add up! Here a 25% penalty just to satisfy two pointless P::C rules:
#! perl -slw use strict; use Benchmark qw[ cmpthese ]; our $o = bless { X=>1 }, 'main'; sub getX1{ my $self = shift; return $self->{X}; } sub getX2{ return $_[0]->{X}; } sub getX3{ $_[0]->{X}; } cmpthese -1, { A=> q[ my $x = $o->getX1(); ], B=> q[ my $x = $o->getX2(); ], C=> q[ my $x = $o->getX3(); ], }; __END__ C:\test>junk19 Rate A B C A 1441709/s -- -11% -20% B 1611352/s 12% -- -10% C 1797147/s 25% 12% --
And that is just one level deep. Imagine (or test) the affect of calling a method that itself needs to call 2 or 3 getter() from one of its sub objects.
The penalties, for what are purely cosmetic affectations, add up.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^15: The Most Essential Perl Development Tools Today (negative)
by tobyink (Canon) on Jan 13, 2013 at 20:03 UTC | |
by BrowserUk (Patriarch) on Jan 13, 2013 at 20:40 UTC | |
by tobyink (Canon) on Jan 14, 2013 at 09:18 UTC | |
by BrowserUk (Patriarch) on Jan 14, 2013 at 12:42 UTC | |
Re^15: The Most Essential Perl Development Tools Today (negative)
by Anonymous Monk on Jan 14, 2013 at 09:37 UTC | |
by BrowserUk (Patriarch) on Jan 14, 2013 at 11:49 UTC | |
by Anonymous Monk on Jan 14, 2013 at 12:00 UTC | |
by BrowserUk (Patriarch) on Jan 14, 2013 at 12:48 UTC |
In Section
Seekers of Perl Wisdom