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;