in reply to Re^2: Not sure what I am doing wrong
in thread Not sure what I am doing wrong
I did a quick test and got the following results:
The text to check was part of a play by Shakespeare, loaded into an array (1 line per element) and the regex used wasRate Raw Regex Assembled Regex Raw Regex 614/s -- -9% Assembled Regex 676/s 10% --
Assembled into a more efficient regex it looks like:qr /this|that|here|there|where/;
Even by eliminating only ONE of the alternations (5 vs 4) a 10% speed-up was obtained.qr /(?:th(?:ere|at|is)|w?here)/
PS: I do not know about 5.10, this was tested in 5.8.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Not sure what I am doing wrong
by massa (Hermit) on Nov 26, 2008 at 14:34 UTC |