This is probably due to inefficient stringification of the object reference. Maybe the stringified value should be put into the PV portion and POK should be set on while doing Perl_sv_2pv_flags ?
I think this evaluation is spot on. If you change the inside-out implementation to something that avoids stringification:
package Class_Inside_Out;
use Scalar::Util qw(refaddr);
my %name;
my %colour;
my %age;
sub new {
my $key = bless \(my $dummy) => shift;
$$key = refaddr ( $key );
my %args = @_;
$name {$$key} = $args {name} || "abigail";
$colour {$$key} = $args {colour} || "pink";
$age {$$key} = $args {age} || 100;
$key;
}
sub name {
my $key = shift;
$name {$$key} = shift if @_;
$name {$$key};
}
sub colour {
my $key = shift;
$colour {$$key} = shift if @_;
$colour {$$key};
}
sub age {
my $key = shift;
$age {$$key} = shift if @_;
$age {$$key};
}
sub format {
my $key = shift;
join " " => $name {$$key}, $colour {$$key}, $age {$$key};
}
You get something much more reasonable:
Rate closure inside_out traditional
closure 177/s -- -43% -45%
inside_out 313/s 76% -- -3%
traditional 321/s 81% 3% --
-
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.
|