in reply to non-scalar hash key
prints:use strict; use warnings; use Benchmark qw(:all) ; my @foo = qw/1 2 3 4 5 6/; my %bar = (pack('b', @foo) => 'elephants'); my @baz = qw/1 2 3 4 5 6/; print $bar{pack('b', @baz)} . "\n"; cmpthese(-5, { 'join' => sub { join('', qw/1 2 3 4 5 6/) }, 'pack' => sub { pack('b', qw/1 2 3 4 5 6/) }, });
% perl test.pl elephants Rate join pack join 1002841/s -- -53% pack 2119814/s 111% -- %
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: non-scalar hash key
by tweetiepooh (Hermit) on Jun 17, 2009 at 16:14 UTC | |
by Arunbear (Prior) on Jun 18, 2009 at 10:05 UTC | |
|
Re^2: non-scalar hash key
by kdejonghe (Novice) on Jun 17, 2009 at 13:06 UTC |