Benchmark: timing 200000 iterations of Big, Pak, Str... Big: 10 wallclock secs (10.36 usr + 0.02 sys = 10.38 CPU) @ 19267.82/s (n=200000) Pak: 8 wallclock secs ( 9.81 usr + 0.03 sys = 9.84 CPU) @ 20325.20/s (n=200000) Str: 9 wallclock secs ( 8.30 usr + 0.02 sys = 8.32 CPU) @ 24038.46/s (n=200000) #### sub mat_hash { my %cells; $cells{$_->[0]}{$_->[1]} = undef for @points; my $ncells = 0; $ncells += keys %{$cells{$_}} for keys %cells; $ncells == $npoints or die; exists $cells{$_->[0]}{$_->[1]} or die for @points; exists $cells{'notfound'} and die; exists $cells{'notfound2'} and die; exists $cells{'notfound3'} and die; return \%cells; } sub mat_look { my $cells = shift; exists $cells->{$_->[0]}{$_->[1]} or die for @points; exists $cells->{'notfound'} and die; exists $cells->{'notfound2'} and die; exists $cells->{'notfound3'} and die; } my $str_ref = str_hash(); my $big_ref = big_hash(); my $pak_ref = pak_hash(); my $mat_ref = mat_hash(); timethese 200000, { Str => sub { str_look($str_ref) }, Big => sub { big_look($big_ref) }, Pak => sub { pak_look($pak_ref) }, Mat => sub { mat_look($mat_ref) }, }; #### #!/usr/bin/env perl #### Benchmark: timing 200000 iterations of Big, Mat, Pak, Str... Big: 10 wallclock secs (10.06 usr + 0.02 sys = 10.08 CPU) @ 19841.27/s (n=200000) Mat: 8 wallclock secs ( 7.51 usr + 0.01 sys = 7.52 CPU) @ 26595.74/s (n=200000) Pak: 10 wallclock secs ( 9.63 usr + 0.01 sys = 9.64 CPU) @ 20746.89/s (n=200000) Str: 8 wallclock secs ( 7.78 usr + 0.02 sys = 7.80 CPU) @ 25641.03/s (n=200000) Benchmark: timing 200000 iterations of Big, Mat, Pak, Str... Big: 10 wallclock secs (10.01 usr + 0.02 sys = 10.03 CPU) @ 19940.18/s (n=200000) Mat: 8 wallclock secs ( 7.52 usr + 0.01 sys = 7.53 CPU) @ 26560.42/s (n=200000) Pak: 10 wallclock secs ( 9.72 usr + 0.01 sys = 9.73 CPU) @ 20554.98/s (n=200000) Str: 8 wallclock secs ( 8.00 usr + 0.02 sys = 8.02 CPU) @ 24937.66/s (n=200000) Benchmark: timing 200000 iterations of Big, Mat, Pak, Str... Big: 10 wallclock secs (10.05 usr + 0.01 sys = 10.06 CPU) @ 19880.72/s (n=200000) Mat: 8 wallclock secs ( 7.47 usr + -0.01 sys = 7.46 CPU) @ 26809.65/s (n=200000) Pak: 9 wallclock secs ( 9.66 usr + 0.02 sys = 9.68 CPU) @ 20661.16/s (n=200000) Str: 9 wallclock secs ( 8.09 usr + 0.01 sys = 8.10 CPU) @ 24691.36/s (n=200000) #### $ perl -v | head -2 | tail -1 This is perl 5, version 26, subversion 0 (v5.26.0) built for darwin-thread-multi-2level