KieranP/Game-Of-Life-Implementations — Issue #2: Horrible PHP Performance
Author: KieranP
Created: 2011-11-17 05:24:09+00:00
State: open

Notes on investigations as to why the PHP implementation is so slow.

Looks like the two foreach loops in the tick() function are the cause.

Attempt: Added timing code around the two foreach loops, and inside the loop, and then subtracting the time for the executed code inside the loop from the overall time around the loop.

Result: Shows that the loop itself (a simple iteration) is taking 0.139s in a 0.167s tick (a whopping 83.2% of the time). The question is, why is the foreach loop taking that long. A quick test shows a 'for' and 'while' blocks are just as slow.

Notes: The array size is 150*40 = 6000. Maybe PHP doesn't cope with large arrays?