#!/usr/bin/perlusestrict;usewarnings;useBenchmark;useList::Utilqw/shuffle/;print"Perl version $]\n";my$N=6;my$M=10**$N;my%subs;formy$n(0..$N){my$m=10**$n;keys(my%h)=$m;#preallocated the hash so it doesn't have to keep growingmy$k="aaaaaa";%h=(map{$k++=>1}1..$m);my@a=shufflekeys%h;if(@a!=$M){@a=(@a)x($M/@a);}my$x;$subs{"10^$n keys"}=sub {$x=$h{$_}for@a;};}Benchmark::cmpthese-3,\%subs;