use Benchmark; my @keys = qw(a b c d e f g h i j); sub _exists { my %keys; exists $keys{$_}{1} for @keys; } sub _keyref { my %keys; $keys{$_} = {} for @keys; } Benchmark::cmpthese(-1, { 'exists' => \&_exists, 'key=ref' => \&_keyref, });