use Benchmark; sub asub { for (1 .. 2000) {} } Benchmark::cmpthese (5000, { 'sub' => sub { asub() }, 'nosub' => sub { for (1 .. 2000) {} }, });