Profiling – is a process of application performance analysis done for the purpose of acquiring data about efficiency (a set of characteristics like CPU times, RAM and resources processing, number of function calls and so on). Accordingly the instrument used for that is called a profiler.
Profilers in most cases are used to find hot-spots in the application (a hot-spot is a part in the code which processing time is inexcusably long) and also for analysis and evaluation of application quality.
XHprof is a hierarchical profiler for PHP with HTML interface. The core is written in C language (the code is ultimately PHP on the level of reports and interface), and for download it’s available as extension for PHP. This profiler knows how to collect data about memory usage, processor resources, number and order of calls of functions and also inclusive time (time spent for the function and all functions started by it) and exclusive time (time spent for the function with no regard to the time taken by the embedded function).
Additionally, XHprof supports ability to compare two runs (hierarchical DIFF report) and aggregate results from multiple runs for data averaging.
XHprof (version 0.9.2, starting with PHP 5.2.0) is available as PECL-package since July 1, 2009. By the way, it’s not available for Windows.
Installation process is as follows:
pecl download xhprof-0.9.2 tar -xvf xhprof-0.9.2.tar.gz cd xhprof-0.9.2/extension phpize ./configure make make install
Then a module in php.ini must be enabled: