in reply to Minimum Hash keys allocated?
With 10,000,000 keys, typical numbers for pre-allocated hash keys was:use warnings; use strict; use Benchmark; my $start = new Benchmark; my $size = 10000000; my %hash; keys(%hash) = $size; for my $i (1..$size) { my $key = "key$i"; $hash{$key} = $key; } my $end = new Benchmark; my $diff = timediff ($end, $start); print "The code ran for \n",timestr($diff),"\n";
Typical numbers with the pre-allocation commented out:19 wallclock secs (17.36 usr + 0.94 sys = 18.30 CPU)
21 wallclock secs (21.23 usr + 0.63 sys = 21.86 CPU)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Minimum Hash keys allocated?
by flexvault (Monsignor) on Sep 27, 2010 at 11:01 UTC |