This is a discussion on Low performance when creating arrays within the PHP General forums, part of the PHP Programming Forums category; Hello, I don't know if this is a normal situtation or it is a bug or I'm doing ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
I don't know if this is a normal situtation or it is a bug or I'm doing something wrong, but my application creates quite big arrays and the php performance is quite low. Below I have made several tests, which shows that creation time of multi-dimensional arrays is growing rapidly. Is this a normal behaviour or maybe there is better solution when making arrays. I use Windows XP, Apache, PHP 4.3.5. Thanks in advance for any answer. $test = Array(); $start = explode(" ", microtime()); for ($i = 0; $i < 100000; $i++) { $test[] = "test"; } $stop = explode(" ", microtime()); print ($stop[1]+$stop[0])-($start[1]+$start[0]); -------Time: 0.24844598770142 $test = Array(); $start = explode(" ", microtime()); for ($i = 0; $i < 100000; $i++) { $test[$i] = Array(); } $stop = explode(" ", microtime()); print ($stop[1]+$stop[0])-($start[1]+$start[0]); --------Time: 0.33644223213196 $test = Array(); $start = explode(" ", microtime()); for ($i = 0; $i < 100000; $i++) { $test[$i] = Array(Array()); } $stop = explode(" ", microtime()); print ($stop[1]+$stop[0])-($start[1]+$start[0]); --------Time: 0.55727505683899 $test = Array(); $start = explode(" ", microtime()); for ($i = 0; $i < 100000; $i++) { $test[$i] = Array(Array(), Array(), Array(), Array(Array())); } $stop = explode(" ", microtime()); print ($stop[1]+$stop[0])-($start[1]+$start[0])."<br/><br/>"; --------Time: 1.4375410079956 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|