#!/usr/bin/perl use strict; use warnings; use version; use Benchmark qw(cmpthese); my $str = "bea" x 100; my $re = qr/(?:be|ea|a)/; cmpthese(-2, { atomic1 => sub { die if $str =~ m/(?>$re+)\d/ }, atomic2 => sub { die if $str =~ m/(?>$re)+\d/ }, normal => sub { die if $str =~ m/$re+\d/ }, ( version->new($]) >= version->new("5.10.0") ? (posessive => sub { die if $str =~ m/$re++\d/ }) : () ), }); __END__ 5.8.8: Rate normal atomic2 atomic1 normal 5000/s -- -4% -18% atomic2 5208/s 4% -- -15% atomic1 6132/s 23% 18% -- 5.11: Rate posessive atomic1 atomic2 normal posessive 59.9/s -- -1% -97% -97% atomic1 60.4/s 1% -- -97% -97% atomic2 1953/s 3159% 3134% -- -9% normal 2156/s 3500% 3472% 10% --