I'm drowning in PHP

muppet scott at asofyet.org
Tue May 15 13:05:42 BST 2007

On May 15, 2007, at 7:12 AM, graham wrote:

> Jonathan Rockway wrote:
>> On Monday 14 May 2007 10:12:31 pm Andy Armstrong wrote:
>>> This is a small gem from some PHP I'm obliged to look at:
>>>      for($i=0; $i<strlen($str); $i++) {
>> Ah, the classic O(n^2) for loop.  Haven't seen that one for quite  
>> a while, especially not in a language with built-in regexes.   
>> Gotta love PHP...
> In a case where n is never likely to be large enough for order  
> notation to come into it. Surely the issue is the waste of  
> programmer, not processor, cycles used. Which has sod all to do  
> with PHP the language - a beginning perl programmer could have done  
> the same...

To wit, i recently helped a co-worker knock the runtime of a perl  
script down from ~20 minutes to 90 seconds simply by creating two  
reverse-lookup hashes to replace hundreds of thousands of linear  
searches.  For strings.

That last 90 seconds has regrown to about four minutes, with at least  
half the time spent in XML::Simple, loading a three megabyte utf8  
data file...

It's all very complicated and would take a scientist to explain it.
   -- MST3K

More information about the london.pm mailing list