#!/usr/bin/perl use strict; use warnings; use Scalar::Util qw( blessed ); use Benchmark qw( cmpthese ); my $obj = bless {}, 'Foo'; my $not_obj; my $result; cmpthese( -1, { eval1 => sub { for ( 0 .. 10_000 ) { $result = eval { $obj->isa('Foo') }; $result = eval { $obj->isa('Bar') }; } }, blessed1 => sub { for ( 0 .. 10_000 ) { $result = blessed($obj) and $obj->isa('Foo'); $result = blessed($obj) and $obj->isa('Bar'); } }, eval2 => sub { for ( 0 .. 10_000 ) { $result = eval { $not_obj->isa('Foo') }; $result = eval { $not_obj->isa('Bar') }; } }, blessed2 => sub { for ( 0 .. 10_000 ) { $result = blessed($not_obj) and $not_obj->isa('Foo'); $result = blessed($not_obj) and $not_obj->isa('Bar'); } }, });