use warnings; use strict; use Benchmark qw/cmpthese/; { package Foo; sub bar { return $_[0] + $_[1] } } BEGIN { *bar = \&Foo::bar } # import cmpthese(-2, { imported => sub { bar(2,3)==5 or die; }, package => sub { Foo::bar(2,3)==5 or die; }, });