use strict; use warnings; use Benchmark qw(cmpthese); use constant kHalfMax => 509; # Must be odd my %Contracts = (1..4 * kHalfMax); # kHalfMax * 2 key/value pairs my $key = kHalfMax; cmpthese (-1, { lookup => \&lookup, refit => \&refit, } ); sub lookup { return if $Contracts{$key} == 1; return if $Contracts{$key} == 1; return if $Contracts{$key} == 1; return if $Contracts{$key} == 1; return if $Contracts{$key} == 1; return if $Contracts{$key} == 1; return if $Contracts{$key} == 1; return if $Contracts{$key} == 1; } sub refit { my $ref = \$Contracts{$key}; return if $$ref == 1; return if $$ref == 1; return if $$ref == 1; return if $$ref == 1; return if $$ref == 1; return if $$ref == 1; return if $$ref == 1; return if $$ref == 1; } #### Rate lookup refit lookup 443125/s -- -32% refit 648621/s 46% --