Created
November 15, 2012 08:36
-
-
Save chernomyrdin/4077441 to your computer and use it in GitHub Desktop.
Get one item from hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w -- | |
use strict; | |
use Benchmark; | |
my %hash; | |
for (1..1e4) { | |
my $key = join($_, "*" x (10*rand), (10*rand)); | |
$hash{$key} = "*" x (100*rand); | |
} | |
timethese( 1e4, { | |
'keys' => sub { my ($key) = keys %hash; }, | |
'each' => sub { my ($key) = each %hash; }, | |
} ); | |
__END__ |
Author
chernomyrdin
commented
Jul 5, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment