is it noise?

sub BenchIt { print "\n\n## $^O $]\n"; use Benchmark qw {:all}; our %hash; for (1001..2000) { $hash{$_}++; } our $key1 = 2000 - int rand 1001; our $key2 = 2000 - int rand 1001; $hash{$key1} = 1; $hash{$key2} = {1..10}; our $xx_global; cmpthese ( -2, { svExist => 'for(1..10_000){$xx_global = exists $hash{$ke +y1} ? 1 : 2}', svValue => 'for(1..10_000){$xx_global = $hash{$key1} ? 1 + : 2}', refExist => 'for(1..10_000){$xx_global = exists $hash{$ke +y2} ? 1 : 2} ', refValue => 'for(1..10_000){$xx_global = $hash{$key2} ? 1 + : 2}', } ); return; }

a few old perls

## msys 5.008008 Rate svValue svExist refValue refExist svValue 212/s -- -0% -10% -16% svExist 212/s 0% -- -10% -16% refValue 235/s 11% 11% -- -6% refExist 250/s 18% 18% 6% -- ## MSWin32 5.008009 Rate svValue refValue refExist svExist svValue 210/s -- -10% -15% -16% refValue 234/s 11% -- -6% -6% refExist 249/s 18% 6% -- -0% svExist 250/s 19% 7% 1% -- ## MSWin32 5.012002 Rate refValue svValue refExist svExist refValue 232/s -- -2% -4% -6% svValue 237/s 2% -- -2% -4% refExist 242/s 4% 2% -- -2% svExist 247/s 6% 4% 2% -- ## MSWin32 5.014001 Rate refValue refExist svExist svValue refValue 245/s -- -4% -5% -5% refExist 254/s 4% -- -1% -1% svExist 258/s 5% 1% -- -0% svValue 258/s 5% 1% 0% -- ## MSWin32 5.016003 Rate refValue svValue svExist refExist refValue 237/s -- -2% -5% -6% svValue 242/s 2% -- -3% -4% svExist 250/s 6% 4% -- -1% refExist 252/s 6% 4% 1% -- ## MSWin32 5.016003 Rate refValue svValue svExist refExist refValue 222/s -- -2% -16% -16% svValue 228/s 2% -- -14% -14% svExist 264/s 19% 16% -- -0% refExist 265/s 19% 16% 0% -- ## MSWin32 5.018002 Rate svValue svExist refValue refExist svValue 234/s -- -9% -10% -13% svExist 258/s 10% -- -0% -4% refValue 258/s 11% 0% -- -4% refExist 269/s 15% 4% 4% -- ## MSWin32 5.020003 Rate refValue refExist svValue svExist refValue 231/s -- -1% -5% -7% refExist 234/s 1% -- -4% -6% svValue 243/s 5% 4% -- -3% svExist 249/s 8% 7% 3% --

laptops fluctuate :)

## msys 5.008008 Rate svValue refValue refExist svExist svValue 223/s -- -5% -8% -9% refValue 235/s 5% -- -4% -4% refExist 244/s 9% 4% -- -0% svExist 244/s 9% 4% 0% -- ## msys 5.008008 Rate svValue svExist refValue refExist svValue 212/s -- -2% -12% -16% svExist 216/s 2% -- -10% -14% refValue 240/s 14% 11% -- -5% refExist 252/s 19% 17% 5% -- ## msys 5.008008 Rate svValue refValue svExist refExist svValue 221/s -- -7% -11% -12% refValue 238/s 8% -- -4% -5% svExist 248/s 12% 4% -- -1% refExist 250/s 13% 5% 1% --

In reply to Re^9: "exists $hash{key}" is slower than "$hash{key}" by Anonymous Monk
in thread "exists $hash{key}" is slower than "$hash{key}" by swl

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.