Tuesday, 24 April 2007
Profile Your Code with Xdebug |
| |
|
| |
Object-oriented programming is in vogue and PHP is no exception. Paul Annesley shows you how to adopt the proper design patterns and built your site on the latest PHP framework. He explains it under the following sections:
What's Going On?
Paul tells you, when you first move towards object-oriented programming, the first thing you might notice is that you are jinxed on what is the execution path to be followed through your code and the framework it’s built on.
The next thing you might notice is that your site is perhaps slower than it was. Object-oriented programming aims to improve the quality, maintainability and reusability of code.
Xdebug
Xdebug 2, currently beta and Paul runs it on 2.0.0RC3. He says, it is a PHP extension, which provides various ways of debugging and analyzing your code on your development server. He shows how to gather profile information for PHP scripts. He adds that Xdebug does much more than output profiling data. It also has the Firebug for backend developers.
WinCacheGrind
WinCacheGrind he says, is a simple way to get information out of your cachegrind output file. It provides a simple tree view of the PHP execution with references to class, function and filenames. The highlight is that it tells you how long each function call took. He provides screenshots to give you a better understanding of the concept.
Kcachegrind
He tells you that if you’re running KDE on Linux, or Mac OS X via Fink than you might like to give KCachegrind a try. It is much more complicated than WinCacheGrind, but presents your cachegrind data in some interesting ways. You can take a look at the screenshots for a better view.
He gives a tip on running your code faster through cache. He advises the following:
- To use your new tools to find the slow points in your scripts
- To make sure slow queries take advantage of your MySQL query cache
- Try out a PHP bytecode cache like APC
- Cache your PHP objects with memcached
- Cache common sections of your generated HTML
- Cache entire pages before sending them
- Make your users cache your pages with Expires, ETag and Last-Modified HTTP headers
|
| |
|
Read the Post
|
| |
|
|
| |
|
|
| |
|