in reply to RE performance

Hi,

My guess is, that your speedup comes from the "optimization" you get by the || operator. If the "test$i" =~ /est/ piece gives a true value (and it does always in your example), no need to evaluate the second part. Thus you "significantly" simplified the regexp.

Bye
 PetaMem

Replies are listed 'Best First'.
Re: Re: RE performance
by Vennis (Pilgrim) on Sep 04, 2002 at 12:34 UTC
    This sounds logic, but this next test, still shows more or less 20% difference.
    for($i=0;$i<100000;$i++){ if("test$i" =~ /(dest|\d)/){ # do stuff; } } for($i=0;$i<100000;$i++){ if("test$i" =~ /dest/ || "test$i" =~ /\d/){ # do stuff; } }