Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy php array gets slower with newer php versions, and how to go around that?
    primarykey
    data
    text
    <p>I have a php based system working perfectly since 2006, which has a backend (CLI, cron) process, processing millions of records, using a big tree-like structure in memory. </p> <p>I've noticed great performance regressions when upgrading a debian machine. </p> <p>So, to research the issue, I wrote a simple script, and downloaded a dozen xampp releases, and run the same script with the different php versions.</p> <pre><code>$start=microtime(true); $n=10; $counter=1; $testarray=Array(); for ($i[1]=0;$i[1]&lt;$n;$i[1]++) for ($i[2]=0;$i[2]&lt;$n;$i[2]++) for ($i[3]=0;$i[3]&lt;$n;$i[3]++) for ($i[4]=0;$i[4]&lt;$n;$i[4]++) for ($i[5]=0;$i[5]&lt;$n;$i[5]++) for ($i[6]=0;$i[6]&lt;$n;$i[6]++) for ($i[7]=0;$i[7]&lt;$n;$i[7]++) $testarray[$i[1]][$i[2]][$i[3]][$i[4]][$i[5]][$i[6]][$i[7]]=$counter++; $end=microtime(true); echo "PHP ".phpversion()." ".round(memory_get_peak_usage(true)/(1024*1024),2)." mbyte max ram, ".round($end-$start,2)." seconds\r\n"; </code></pre> <p>I run the same script against xampp win32 1.6.0a through win32 1.7.7-vc9, with the following results:</p> <pre><code> - PHP 5.2.1 890.25 mbyte max ram, 12.43 seconds - PHP 5.2.1 890.25 mbyte max ram, 12.37 seconds - PHP 5.2.2 890.25 mbyte max ram, 12.43 seconds - PHP 5.2.3 890.25 mbyte max ram, 12.38 seconds - PHP 5.2.4 890.25 mbyte max ram, 12.5 seconds - PHP 5.2.5 890.25 mbyte max ram, 12.28 seconds - PHP 5.2.5 890.25 mbyte max ram, 12.31 seconds - PHP 5.2.6 890.25 mbyte max ram, 12.52 seconds - PHP 5.2.6 890.25 mbyte max ram, 12.54 seconds - PHP 5.2.8 890.25 mbyte max ram, 12.72 seconds - PHP 5.2.9 890.25 mbyte max ram, 12.53 seconds - PHP 5.3.0 975.5 mbyte max ram, 18.28 seconds - PHP 5.3.1 975.5 mbyte max ram, 18.06 seconds - PHP 5.3.5 975.5 mbyte max ram, 18.49 seconds - PHP 5.3.8 975.5 mbyte max ram, 17.97 seconds - PHP 5.3.8 975.5 mbyte max ram, 18.11 seconds </code></pre> <p>Notes: - I don't use xampp or windows on servers, but this was the easiest way to test through different versions at once. - I tried to google for this problem a few times, but didn't get any relevant results - The speed loss is about the same (50% longer runtime) on the servers - I don't think that a slowdown of this kind is acceptable from any framework or compiler, - even in spite of new features the old ones should work just as well as before. I can't tell my boss, that the same computer with the same software can't do the same job anymore, because we dist-upgraded the debian on it... That would look like some windows upgrade. :) </p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload