|
Posted by Curtis on 12/08/05 09:55
Working on a text filter, which involves a lot of scan and
text replacement.
A similar program we studied used PHP character-by-character
loops and was extremely inefficient.
We found the following considerably more efficient,
submitting each paragraph in turn to a series like this:
if (strstr($text, "/"))
$text = preg_replace("/ ETC.
if (strstr($text, "*"))
$text = preg_replace("/ ETC.
if (strstr($text, "^"))
$text = preg_replace("/ ETC.
This sequence goes on for a goodly number of characters.
Using the tests before the preg_replaces sped up the program
considerably. But I wonder if anyone can suggest an
algorithm or PHP structure/function(s) which might somehow
combine these tests for even more speed?
Processing 15,000 characters of text fairly heavily loaded
with stuff-to-do is taking between .1 and .2 sec on an
unloaded 500MHz WAMP server. I'm not sure how this will
translate into speed or sluggishness on a busier server, but
I'd like to look for ways to rev things up.
Suggestions?
--
Curtis
Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to ideas.
Navigation:
[Reply to this message]
|