Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Perl Hash Performance Hits Brick Wall!

by dave_the_m (Monsignor)
on Aug 17, 2015 at 06:15 UTC ( [id://1138830]=note: print w/replies, xml ) Need Help??


in reply to Perl Hash Performance Hits Brick Wall!

I can't reproduce this (linux, 5.20.2):
use Time::HiRes qw(time); my $n = $ARGV[0]; my %h; for (1..$n) { my $key = sprintf "%06d", $_; $h{$key} = 1; } my @a; my $t1 = time; @a = keys %h; my $t2 = time; printf "time = %.3f; secs per 1M keys: %.3f\n", ($t2-$t1), ($t2-$t1) / $n * 1_000_000;
I get the following, which shows that the time per key is nearly constant:
$ perl foo 1000000 time = 0.400; secs per 1M keys: 0.400 $ perl foo 2000000 time = 0.845; secs per 1M keys: 0.423 $ perl foo 4000000 time = 1.752; secs per 1M keys: 0.438 $ perl foo 8000000 time = 3.792; secs per 1M keys: 0.474 $ perl foo 16000000 time = 9.213; secs per 1M keys: 0.576

Dave.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-18 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found