Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by ikegami (Pope)
on May 19, 2018 at 01:04 UTC ( #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
Node Status?
node history
Node Type: note [id://1214889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2019-04-23 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (118 votes). Check out past polls.

    Notices?