Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^9: "exists $hash{key}" is slower than "$hash{key}"

by Anonymous Monk
on Jan 09, 2020 at 09:15 UTC ( [id://11111234]=note: print w/replies, xml ) Need Help??


in reply to Re^8: "exists $hash{key}" is slower than "$hash{key}"
in thread "exists $hash{key}" is slower than "$hash{key}"

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% --

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11111234]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found