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

Re: Re:x2 Counting keys with defined or undefined elements in a hash

by jsprat (Curate)
on Jun 05, 2003 at 18:46 UTC ( [id://263453]=note: print w/replies, xml ) Need Help??


in reply to Re:x2 Counting keys with defined or undefined elements in a hash
in thread Counting keys with defined or undefined elements in a hash

I msg'd you, but you weren't around, so I'll post here.

The benchmark isn't benchmarking the giant hash - the parameter being passed to the sub is not what you think it is (which explains the amazing speed)! Just use %h directly in the sub to see the difference.

Try using this modified sub by_for to show how the parameters are being passed:

sub by_for { my $h = shift; die scalar keys %$h unless scalar keys %$h; my @def; $def[ defined $_ ? 1 : 0]++ for values %$h; @def; }

It dies when the benchmark is run.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found