Vennis has asked for the wisdom of the Perl Monks concerning the following question:
While looking at performance of a script of mine, i tested an iteration script, i found out that using a little bit more complex Regular Expressions isn't equal or faster, even though it's code is smaller (and looks nicer).
I realize this is a minor test and a fast conclusion, i hope anyone can tell me why this difference is and maybe tell me if you have experienced such differences yourself ?
Did i test this wrongly? Or would it seriously be an option to fragment a complex RE for better performance (if possible) ?
for($i=0;$i<100000;$i++){ if("test$i" =~ /(est|\d)/){ # do stuff; } } is at least 20% slower (+/- 3s vs 2.3s yes, slow machine :-) then: for($i=0;$i<100000;$i++){ if("test$i" =~ /est/ || "test$i" =~ /\d/){ # do stuff; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RE performance
by RMGir (Prior) on Sep 04, 2002 at 12:34 UTC | |
by Zaxo (Archbishop) on Sep 04, 2002 at 14:19 UTC | |
by RMGir (Prior) on Sep 04, 2002 at 14:38 UTC | |
by japhy (Canon) on Sep 06, 2002 at 14:38 UTC | |
by PodMaster (Abbot) on Sep 05, 2002 at 06:44 UTC | |
|
Re: RE performance
by PetaMem (Priest) on Sep 04, 2002 at 12:23 UTC | |
by Vennis (Pilgrim) on Sep 04, 2002 at 12:34 UTC | |
|
Re: RE performance
by demerphq (Chancellor) on Sep 04, 2002 at 17:07 UTC | |
by Vennis (Pilgrim) on Sep 05, 2002 at 10:04 UTC |