#!/usr/bin/perl use strict; use warnings; use Benchmark 'cmpthese'; my $self = bless [123], '::main'; cmpthese( 10000000, { normal => $self->a(), optimized => $self->b(), direct => $self->c(), }); exit(0); sub a { # old school accessor $self->get_value(); } sub b { # optimized accessor $self->get_value2(); } sub c { # fast and nasty, non oo accessor $self->[0]; } sub get_value { my $self = shift; return $self->[0]; } sub get_value2 { $_[0]->[0]; }