Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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 ( #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
Node Status?
node history
Node Type: note [id://263453]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2016-08-31 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (433 votes). Check out past polls.