rolisz's site

PHP benchmarking

While working on my framework, I got to a point when I had to store quite a lot of data during the execution of the script. My first thought was to use an as­so­cia­tive array. But then I thought maybe objects are faster/use less memory. ┬áSo I decided to test this. I used XDebug to get in­for­ma­tion about memory usage and I am running WampServer x64 on Windows 7. I quickly whipped up a script to fill an array with 1000 keys and arbitrary values and another one to create an object and create 1000 properties for it.

<?php<br ?> //Initial memory
$memory1 = xdebug_memory_usage( );

$data = array();
for ($i=0;