in reply to Improving performance
Hello dominic01,
The Camel Book (4th Edition, 2012) has a section on “Time Efficiency” which contains the following (p. 692):
Short-circuit alternation is often faster than the corresponding regex. So:
print if /one-hump/ || /two/;is likely to be faster than:
print if /one-hump|two/;at least for certain values of one-hump and two.
Also, if your regex is more likely to find a space than a punctuation character, test for the space first. Only profiling will show whether these kinds of tweaks make significant improvements, but they’re worth a try.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Improving performance
by LanX (Saint) on Mar 14, 2015 at 12:57 UTC |