One of my applications ran slow. On detail page, about 300 records are returned from DB and shown on the page, it however took about 5 seconds to render the whole page.
How to find out what’s going on behind, was it because of DB, application or data transmission? To answer this question, a profiling tool is helpful.
For PHP, Xdebug is the right tool, it allows you to debug code, profile applications.
Below are steps to enable this tool.
1. Download the correct version of Xdebug from
http://www.xdebug.org/
2. Enable Xdebug
In PHP.ini, add the following line to load xdebug(the actual DLL depends on your own version of PHP, in my case, it’s PHP5.4 on Windows non-thread-safe compiled by VC++9.
zend_extension = .extphp_xdebug-2.3.2-5.4-vc9-nts.dll
;Enable profiler
xdebug.profiler_enable=1
;Specify output folder
xdebug.profiler_output_dir=D:PHPlog
3. Once the above are done, re-start Web server to load/enable Xdebug
Now when you open your browser and access the web application, you should be able to see profiler output files under D:PHPlog
4. Install QCacheGrind to read the output file to check your application’s performance.
Below is the official documentation of Xdebug profiler
http://www.xdebug.org/docs/profiler