in reply to Re^4: Why does global match run faster than none global?
in thread Why does global match run faster than none global?
I noticed that your figures are about an order of magnitude slower in absolute terms,
There appears to be nothing wrong with my set-up, and nothing I tried has allowed me to start and stop the regex engine in less than 1 microsecond.
I strongly suspect that all the timing showing millions/s are wrong. I think that the posters have tested code along the lines of:
use Benchmark qw[ cmpthese ]; my $str = '123456789'; cmpthese -1, { a=>q[ my ($a,$b) = $str =~ m/(23)[^8]+(8)/g; ], b=>q[ my ($a,$b) = $str =~ m/(23)[^8]+(8)/; ], c=>q[ my ($a) = $str =~ m/(23)/g ], d=>q[ my ($a) = $str =~ m/(23)/; ], };;
Note the my which means that when the tested are evaluated $str will be undefined.
|
|---|