Xhprof Installation & amp; use, xhprof

Source: Internet
Author: User

Xhprof Installation & use, xhprof
I heard from my colleagues about a php performance analysis extension called xhprof. I recently learned about it.

XHProf is a lightweight hierarchical performance measurement analyzer. In the data collection phase, it tracks the number of calls and measurement data, and displays the dynamic called arc chart of the program. It calculates exclusive performance metrics in the reporting and post-processing phases, such as the elapsed time, CPU computing time, and memory overhead. Function performance reports can be terminated by callers and callers. In the data collection phase, XHProf detects recursive functions by calling the graph loop, and avoids recursive calls by assigning a unique depth name.

The following describes how to install and use it.

1. Compile and install

wget http://pecl.php.net/get/xhprof-0.9.2.tgz tar zxf xhprof-0.9.2.tgzcd xhprof-0.9.2/extension/sudo phpize./configure --with-php-config=/usr/local/php/bin/php-configsudo makesudo make install


2. Configure php. ini
Add in php. ini
[xhprof]extension=xhprof.so;; directory used by default implementation of the iXHProfRuns; interface (namely, the XHProfRuns_Default class) for storing; XHProf runs.;;xhprof.output_dir=<directory_for_storing_xhprof_runs>xhprof.output_dir=/tmp/xhprof


Note: For a 64-bit system, copy the xhprof. so file to the related lib64 directory.

3. Add the analysis code to the PHP code

<? Pho // cpu: Memory // if the two are together: XHPROF_FLAGS_CPU + Memory xhprof_enable (XHPROF_FLAGS_CPU + Memory); // php code to be tested $ data = xhprof_disable (); // return running data // This directory exists in the downloaded package of xhprof_lib. Remember to include the directory in the running php code include_once "xhprof_lib/utils/xhprof_lib.php "; include_once "xhprof_lib/utils/xhprof_runs.php"; $ objXhprofRun = new XHProfRuns_Default (); // The first parameter j is xhprof_disable () run information returned by the function // The second parameter is a custom namespace string (any string), // return the run ID, use this ID to view the relevant running result $ run_id = $ objXhprofRun-> save_run ($ data, "xhprof"); var_dump ($ run_id );


4. view the running result
Copy the xhprof_lib & xhprof_html directory to the accessible address to access xxx/xhprof_html/index. php? Run = $ run_id & source = bluefrog. You can see the running status of your php code. The following describes some parameters that indicate that the random Time includes all the execution Time of the sub-function. Exclusive Time/Self Time: the Time consumed by the function execution, excluding the Time consumed by the subtree. The Time that Wall Time took or the Time when the Wall clock was suspended. CPU Time user consumed Time + kernel consumed Time: CPU occupied by the CPU exclusive function itself, including the CPU occupied by the CPU used by the sub-function


Note: The extension ctype is required.


Reference: http://www.lai18.com/content/323747.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.