in reply to Re^4: POE OO sessions - accessing overwritten methods
in thread POE OO sessions - accessing overwritten methods
Interesting. But they are quite wrong (see above). They start out with a factual truth: passing in by @_ is fastest. (I wonder if passing in a single array ref would be faster ... one way to find out!) However, they then go and explain how they'll use this "fast" method to go and make it readable and extendable. Well, guess what. It's not.
Rather than starting out with the fastest method and making it more readable, they should have evaluated all methods, and picked the most readable and fast method. They discarded all alternatives over a perceived speed difference, and then used up way more than that speed difference in making it readable. Kudos for making it readable and forward-thinking. A pox for thinking inside an artificial box.
Update: Yes, a major typo in the code screwed this up. Ok, so it's not significantly slower. I still think it's unreadable :-)
#! /usr/bin/perl use Benchmark qw(cmpthese); use constant {OBJECT => 0, KERNEL => 1, HEAP => 2, SESSION => 3, }; cmpthese( 0, { POE => sub { poe_style(qw(a b c d)); }, Normal => sub { regular_style(qw(a b c d)); }, Ref_Copy => sub { reg_ref('a', [qw(b c d)]); }, Ref_Named => sub { ref_named('a', { kernel => 'b', heap => 'c', session => 'd', } ); }, Named => sub { named_style('a', kernel => 'b', heap => 'c', session => 'd', ); }, Shift => sub { shift_style(qw(a b c d)); }, } ); sub poe_style { my ($self, $kernel, $heap, $session) = @_[ OBJECT, KERNEL, HEAP, S +ESSION ]; 0; } sub regular_style { my $self = shift; my ($kernel, $heap, $session) = @_; 0; } sub reg_ref { my $self = shift; my ($kernel, $heap, $session) = @$_[0]; 0; } sub named_style { my $self = shift; my %opts = @_; 0; } sub ref_named { my $self = shift; my $opts = $_[0]; 0; } sub shift_style { my $self = shift; my $kernel = shift; my $heap = shift; my $session = shift; 0; }
Short version: The calling types they said would be slower than "normal" are. But they're all faster than the one they ended up with. The unintuitiveness of this style still causes problems. As in calling SUPER.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: POE OO sessions - accessing overwritten methods
by BrowserUk (Patriarch) on Feb 12, 2005 at 18:53 UTC | |
by Tanktalus (Canon) on Feb 12, 2005 at 19:23 UTC |