Skip to content

Instantly share code, notes, and snippets.

/b.pl

Created July 26, 2010 11:03
Show Gist options
  • Save anonymous/490426 to your computer and use it in GitHub Desktop.
Save anonymous/490426 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use strict;
use Benchmark;
my $h = { map { $_, $_ } 1..10000 };
timethese( 1000, {
each => sub{ my $i = 0; while( my ($k, $v) = each %$h ) { $i++ } },
values => sub{ my $i = 0; foreach my $v (values %$h) { $i++ } },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment