shmem has asked for the wisdom of the Perl Monks concerning the following question:
do you have a clue about why
#!/usr/bin/perl -wl use strict; use Benchmark qw (cmpthese); my $ref = sub { @_ }; sub foo { @_ } cmpthese(-1, { refcall => sub { @_=(1); $ref -> (@_) }, named => sub { @_=(1); foo (@_) }, goto => sub { @_=(1); goto $ref }, } );
yields the following
Rate refcall named goto refcall 735179/s -- -1% -24% named 742317/s 1% -- -24% goto 973307/s 32% 31% --
unexpected results? I expected that
Reality, as often, seems to be the other way round.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: named sub, subref and magic goto speed
by ysth (Canon) on Dec 14, 2006 at 07:31 UTC | |
by shmem (Chancellor) on Dec 14, 2006 at 08:57 UTC | |
by ikegami (Patriarch) on Dec 14, 2006 at 09:01 UTC | |
by ysth (Canon) on Dec 14, 2006 at 09:51 UTC | |
|
Re: named sub, subref and magic goto speed
by ysth (Canon) on Dec 14, 2006 at 07:28 UTC | |
by Limbic~Region (Chancellor) on Dec 14, 2006 at 13:41 UTC | |
by ysth (Canon) on Dec 14, 2006 at 21:05 UTC | |
by ikegami (Patriarch) on Dec 14, 2006 at 16:45 UTC | |
by Limbic~Region (Chancellor) on Dec 14, 2006 at 16:50 UTC | |
by ikegami (Patriarch) on Dec 14, 2006 at 16:54 UTC | |
|