Use of multi-dimensional arrays to represent data structures

one of the key questions we encountered in the final phase become, why need to we use SplFixedArray as opposed to Hypertext Preprocessor arrays? we’re now equipped to explore the answer. We came throughout the idea that personal home page arrays are without a doubt not arrays as opposed to hash maps. allow us to run a small instance code in php 5.x model to peer the memory utilization of a Hypertext Preprocessor array.


allow us to create an array with a hundred,000 specific php integers. As i am running a sixty four bit machine, I count on every integer to take eight bytes every. So we are able to have around 800,000 bytes of memory ate up for the array. right here is the code:

$startMemory = memory_get_usage();
$array = range(1,100000);
$endMemory = memory_get_usage();
echo ($endMemory - $startMemory)." bytes";

If we run this code in our command prompt, we are able to see an output of 14,649,040 bytes. yes, it is correct. The memory…

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x