How can you determine the performance consequences of your PHP code if you are not familiar with the internals? Are there ways to figure out how your code is being executed (besides simply load testing it)? I am looking for things like memory usage, the execution time for algorithms.
Perhaps Joel would say, "learn C, then read the internals", but I really don't have time to learn C right now (though I'd love to, actually).
Lack of caching strategy Imagine that you have a PHP content management system that powers a news website. Each time a visitor clicks on a story, a database query is executed to retrieve the story content. It's easy to see that thousands of visitors to hundreds of stories could put considerable strain on a database.
Use the Xdebug extension to profile PHP code.
If you're not familiar with valgrind or similar, then to add to @Jordi Bunster's answer...
When you've had profiling on in Xdebug, you can open the dumped profile files in KCacheGrind or WinCacheGrind to get a graphical view of what is taking the time in your code.
Fortunately the xdebug documentation also explains this in detail as well as how to interpret the results: http://xdebug.org/docs/profiler
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With