#!/usr/bin/perl -- use strict; use warnings; use Benchmark qw( cmpthese ); # Make bytes:: functions available, but use character semantics. use bytes (); our $smileys = "\x{263a}" x 10_000; our $empty = "\x{263a}"; chop $empty; cmpthese -1, { bytes => q{ my $c=0; ( bytes::length($empty) or bytes::length($smileys) ) and ++$c for 1 .. 1000; }, utf8 => q{ my $c=0; ( length($empty) or length($smileys) ) and ++$c for 1 .. 1000; }, ord => q{ my $c=0; ( ord( $empty ) or ord( $smileys ) ) and ++$c for 1 .. 1000; }, 'ne""' => q{ my $c=0; ( $empty ne '' or $smileys ne '' ) and ++$c for 1 .. 1000; }, }; __END__ C:\test>junk8 Rate bytes ord ne"" utf8 bytes 1379/s -- -72% -75% -76% ord 4992/s 262% -- -10% -13% ne"" 5566/s 304% 12% -- -3% utf8 5757/s 317% 15% 3% --