I read your node - interesting, thanks. But I can't get results like yours. Could it be because the number of iterations in your test are too low?

Putting get_value() and get_value2() declarations at the beginning of program after the "my $self" line, I get:

Rate normal optimized direct normal 174625/s -- -27% -60% optimized 240602/s 38% -- -45% direct 435374/s 149% 81% --

Moving the subs to just above sub a() declaration, I get

Rate normal optimized direct normal 172275/s -- -28% -61% optimized 239252/s 39% -- -46% direct 444444/s 158% 86% --

I've tried a few more re-arrangements of the code layout, and I can't get the reversal that you did. All re-arrangements I've tried have 'direct' at 145-155%. Any chance you can post the code so I can duplicate the results? Logically, I would think that asking for the value of an arrayref element is going to be faster than calling a sub to do so, so the benchmarks appear to be logical to me.


In reply to Re^2: Unexpected OO accessor benchmarks by cLive ;-)
in thread Unexpected OO accessor benchmarks by cLive ;-)

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.