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.

//Initial memory
$memory1 = xdebug_memory_usage( );

$data = array();
for ($i=0; $i\<100; 

URL routing with PHP

I still remember the first website I made. I shudder when I think back at those days. Lots and lots of copy-paste code, inexistent or crappy doc­u­men­ta­tion ("paginarea efectiv and don't mess with it"), poorly named variables ($cv, $cva, $x). But con­sid­er­ing I was the only developer and probably the only guy who saw the code, it wasn't that bad, because I was the one regretting it later on, when I had to upgrade the site :)). But there is one thing that was awful for the users too: the URLs. At the time (4 years ago) I didn't know about pretty urls. I could filter the content continue.