in reply to Why does global match run faster than none global?

The string '123456789' is very short. Try testing with a very long string:

our $s = '123456789' x 100_000; cmpthese -1, { a=>q[ my ($a,$b) = $s =~ m/(23)[^8]+(8)/g; ], b=>q[ my ($a,$b) = $s =~ m/(23)[^8]+(8)/; ], c=>q[ my ($a) = $s =~ m/(23)/g ], d=>q[ my ($a) = $s =~ m/(23)/; ], };

Outputs:

Rate a c d b a 7.65/s -- -34% -99% -99% c 11.7/s 52% -- -99% -99% d 1336/s 17371% 11358% -- -3% b 1380/s 17950% 11738% 3% --