You are here: Improve this algorithm? « All PHP « IT news, forums, messages
Improve this algorithm?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация