Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: '%hash = ()' is slower than 'undef %hash'

by ikegami (Patriarch)
on May 19, 2018 at 01:04 UTC ( [id://1214889]=note: print w/replies, xml ) Need Help??


in reply to '%hash = ()' is slower than 'undef %hash'

I see the opposite. Where's your test? I never trust a benchmark I don't see; they're too easy to get wrong.

>perl a.pl Rate test2 test1 test2 225043/s -- -5% test1 236071/s 5% -- >perl a.pl Rate test2 test1 test2 233861/s -- -5% test1 247248/s 6% -- >perl a.pl Rate test2 test1 test2 224170/s -- -8% test1 243265/s 9% --
$ perl a.pl Rate test2 test1 test2 194855/s -- -10% test1 217061/s 11% -- $ perl a.pl Rate test2 test1 test2 200313/s -- -5% test1 210977/s 5% -- $ perl a.pl Rate test2 test1 test2 195321/s -- -4% test1 203538/s 4% --
use strict; use warnings; use Benchmark qw( cmpthese ); sub test1 { my %h = 'a'..'z'; %h = (); } sub test2 { my %h = 'a'..'z'; undef %h; } cmpthese(-3, { test1 => \&test1, test2 => \&test2, });

Log In?
Username:
Password:

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

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

    No recent polls found