Nah - your results are way too close. On slower hardware lexicals are clearly fastest, globals come in second and symbolic refs in last place. This is all easily explained in terms of involved opnodes. Symbolic refs add a handful of nodes, and globals are one opnode heavier than lexicals.

Benchmark: running use_global_hash, use_global_vars, use_lexical_hash, + each for at least 10 CPU seconds... use_global_hash: 11 wallclock secs (10.45 usr + 0.00 sys = 10.45 CPU) + @ 112.63/s (n=1177) use_global_vars: 11 wallclock secs (10.55 usr + 0.00 sys = 10.55 CPU) + @ 83.32/s (n=879) use_lexical_hash: 11 wallclock secs (10.48 usr + 0.00 sys = 10.48 CPU +) @ 120.71/s (n=1265) Rate use_global_vars use_global_hash use_lexical_ +hash use_global_vars 83.3/s -- -26% +-31% use_global_hash 113/s 35% -- + -7% use_lexical_hash 121/s 45% 7% + --

In reply to Re: Re: Symbolic refs aka. dynamic variables again by diotalevi
in thread Symbolic refs aka. dynamic variables again by Jenda

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.