in reply to Re^4: Performance optimization question
in thread Performance optimization question

YMMV :-)

It did :)

If you add a hits counter as in my benchmark above, you'll see the reason why. Buk2 does not match anything at all (and fails slowly) in your benchmark:

c:\test>junk6-b Rate orig Buk1 JOOST Buk2 jwkrahn orig 1.59/s -- -30% -55% -59% -63% Buk1 2.29/s 44% -- -36% -41% -47% JOOST 3.57/s 125% 56% -- -8% -18% Buk2 3.88/s 144% 70% 9% -- -11% jwkrahn 4.35/s 173% 90% 22% 12% -- { Buk1 => 203, Buk2 => 0, JOOST => 203, jwkrahn => 203, orig => 203 } ...............*********

And that intrigued me, until I noticed that you are not chomping your data. Once you chomp it, you'll find that Buk2 matches the same number as the others, and runs much (1100%) faster than grep:

c:\test>junk6-b Rate orig Buk1 JOOST jwkrahn Buk2 orig 1.59/s -- -29% -59% -64% -97% Buk1 2.23/s 40% -- -42% -49% -96% JOOST 3.84/s 141% 72% -- -12% -93% jwkrahn 4.37/s 175% 96% 14% -- -92% Buk2 53.0/s 3231% 2280% 1281% 1113% -- { Buk1 => 203, Buk2 => 203, JOOST => 203, jwkrahn => 203, orig => 203 +}

Alternatively, just add /s to the regex in Buk2 in your benchmark, and it will also allow Buk2 to work, but it will only be 500% faster.

c:\test>junk6-b Rate orig Buk1 JOOST jwkrahn Buk2 orig 1.59/s -- -30% -55% -63% -94% Buk1 2.27/s 43% -- -36% -48% -92% JOOST 3.54/s 122% 56% -- -18% -88% jwkrahn 4.33/s 172% 91% 22% -- -85% Buk2 28.5/s 1693% 1155% 707% 559% -- { Buk1 => 203, Buk2 => 203, JOOST => 203, jwkrahn => 203, orig => 203 +}

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."