use Benchmark(cmpthese); cmpthese(100_000, { 'a' => sub { $_ = 'this that this those this these.'; $a = () = /this/g; }, 'b' => sub { $_ = 'this that this those this these.'; $a++ while(s/this//); } }); #### Rate a b a 458716/s -- -7% b 492611/s 7% --