#!/usr/bin/perl # sub_speed.plx -- compare speed for calling sub package Foo; sub do_nothing { } package main; use strict; use warnings; use Benchmark qw( cmpthese ); my $foo = bless {}, 'Foo'; sub do_nothing { } cmpthese( -1, { k1 => sub { $foo->do_nothing }, k2 => sub { Foo->do_nothing }, k3 => sub { Foo::do_nothing }, k4 => sub { do_nothing }, k5 => sub { &do_nothing }, });