Reults of my fairest approximation:
Rate copy nocopy inline_copy inlin +e_nocopy copy 534208/s -- -9% -13% + -23% nocopy 587704/s 10% -- -4% + -16% inline_copy 610942/s 14% 4% -- + -12% inline_nocopy 697762/s 31% 19% 14% + --
use strict; use warnings; use Benchmark qw( cmpthese ); sub attrib_copy { my ($self) = @_; $self->{attrib} } sub attrib_nocopy { $_[0]->{attrib} } our $self = bless({ attrib => 'some_value' }); my %tests = ( copy => 'my $x = do { local @_ = $self; &main::attrib_cop +y };', nocopy => 'my $x = do { local @_ = $self; &main::attrib_noc +opy };', inline_copy => 'my $x = do { local @_ = $self; my ($self) = @_; +$self->{attrib} };', inline_nocopy => 'my $x = do { local @_ = $self; +$_[0]->{attrib} };', ); $_ = 'use strict; use warnings; our $self; ' . $_ for values %tests; cmpthese(-3, \%tests);
See how you can almost get the same benefit from not copying the @_ into local vars?
In reply to Re: Perl keyword like the C/C++ keyword 'inline'
by ikegami
in thread Perl keyword like the C/C++ keyword 'inline'
by sadarax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |