use Benchmark qw[ timethis ]; timethis( 10, sub { my $x = 'A' <=> 'B' } ); Argument "B" isn't numeric in numeric comparison (<=>) at (eval 12) line 1. Argument "A" isn't numeric in numeric comparison (<=>) at (eval 12) line 1. timethis 10: 0 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU) (warning: too few iterations for a reliable count)