Rate bt_c mult bt opt mod chop bt_c 180870/s -- -1% -5% -28% -62% -74% mult 181987/s 1% -- -4% -27% -62% -74% bt 189426/s 5% 4% -- -24% -60% -73% opt 249612/s 38% 37% 32% -- -48% -64% mod 476214/s 163% 162% 151% 91% -- -31% chop 692944/s 283% 281% 266% 178% 46% -- #### use Benchmark 'cmpthese'; $x = int (1_000_000 * rand 1_000_000); cmpthese( -3, { mult => sub { $x =~ /(\d)*(\d)/ }, bt_c => sub { $x =~ /(\d*)(\d)/ }, bt => sub { $x =~ /\d*(\d)/ }, opt => sub { $x =~ /(\d)$/ }, mod => sub { $x % 10 }, chop => sub { my $x= $x; chop $x }, }); #### Rate mult bt_c bt opt mod chop mult 180759/s -- -1% -7% -31% -62% -71% bt_c 182581/s 1% -- -6% -31% -62% -70% bt 193680/s 7% 6% -- -26% -60% -69% opt 263234/s 46% 44% 36% -- -45% -57% mod 481067/s 166% 163% 148% 83% -- -22% chop 618559/s 242% 239% 219% 135% 29% -- #### use Benchmark 'cmpthese'; $x = int (1_000_000 * rand 1_000_000); cmpthese( -3, { mult => sub { $x =~ /(\d)*(\d)/ }, bt_c => sub { $x =~ /(\d*)(\d)/ }, bt => sub { $x =~ /\d*(\d)/ }, opt => sub { $x =~ /(\d)$/ }, mod => sub { $x % 10 }, chop => sub { local $x; chop $x }, });