Agreed with the previous replies.
You missed a few calling conventions,
cmpthese( -1, {
k1 => sub { $foo->do_nothing },
k2 => sub { Foo->do_nothing },
k3 => sub { Foo::do_nothing },
k4 => sub { do_nothing },
k5 => sub { &do_nothing },
k6 => sub { do_nothing() },
k7 => sub { Foo::do_nothing()},
k8 => sub { &Foo::do_nothing },
});
and even at that, I left out some. Results:
Rate k2 k1 k3 k4 k6 k7 k5 k8
k2 379516/s -- -14% -31% -34% -35% -38% -48% -48%
k1 442514/s 17% -- -20% -24% -24% -28% -39% -40%
k3 550801/s 45% 24% -- -5% -6% -10% -24% -25%
k4 579231/s 53% 31% 5% -- -1% -6% -20% -21%
k6 584645/s 54% 32% 6% 1% -- -5% -20% -20%
k7 614031/s 62% 39% 11% 6% 5% -- -16% -16%
k5 727406/s 92% 64% 32% 26% 24% 18% -- -1%
k8 735179/s 94% 66% 33% 27% 26% 20% 1% --
Evidently your box is considerably faster than mine.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.