Home Backend Development PHP Tutorial PHP performance monitoring extension xhprof performance analysis tool

PHP performance monitoring extension xhprof performance analysis tool

Jul 25, 2016 am 09:13 AM

The PHP performance monitoring extension xhprof is generally a good tool. This section introduces the installation and usage process under Ubuntu.

Install xhprof:

  1. wget http://pecl.php.net/get/xhprof-0.9.2.tgz
  2. tar zxf xhprof-0.9.2.tgz
  3. cd xhprof-0.9.2/extension/
  4. sudo phpize
  5. ./configure --with-php-config=/usr/local/php/bin/php-config
  6. sudo make
  7. sudo make install
Copy the code

In order to view the debugging results graphically, you must also To install the tool graphviz, you can directly use apt-get to install it under ubuntu. The command is: sudo apt-get install graphviz. If it is another system, you may have to use some twists and turns. The command is as follows:

  1. wget http://www.graphviz.org/pub/graphviz/stable/sources/graphviz-2.24.0.tar.gz
  2. tar zxf graphviz-2.24.0.tar.gz
  3. cd graphviz- 2.24.0
  4. ./configure
  5. make && make install
Copy the code

Next configure php.ini

Add in php.ini:

  1. [xhprof]
  2. extension=xhprof.so;
  3. ; directory used by default implementation of the ixhprofruns
  4. ; interface (namely, the xhprofruns_default class) for storing
  5. ; xhprof runs.
  6. ;
  7. ;xhprof.output_dir =
  8. xhprof.output_dir=/tmp/xhprof
Copy code

Note: If it is a 64-bit system, you need to copy the xhprof.so file to the relevant lib directory (lib64)

After modification, restart apache and look at phpinfo. There should be information about xhprof.

Add the code to the php to be tested

  1. // cpu:xhprof_flags_cpu Memory: xhprof_flags_memory
  2. // If both together: xhprof_flags_cpu + xhprof_flags_memory
  3. xhprof_enable(xhprof_flags_cpu + xhprof_ flags_memory);
  4. //PHP code to be tested
  5. $data + /utils/xhprof_runs.php";
  6. $objxhprofrun = new xhprofruns_default();
  7. // The first parameter j is the running information returned by the xhprof_disable() function
  8. // The second parameter is the custom namespace character String (any string),
  9. //Return the running id, use this id to view the relevant running results
  10. $run_id = $objxhprofrun->save_run($data, "xhprof");
  11. var_dump($run_id);
  12. Copy the code
View the running results: Copy the xhprof_lib&&xhprof_html related directories to an accessible address Visit xxx/xhprof_html/index.php?run=$run_id to see the running status of your php code. $run_id is the content output in the above page. Remember to include the two files under xhprof_lib. If you don't want to use this method, you can also directly output the relevant printing information, that is, directly print_r out the value of $data above.

Parameter description:

Inclusive time includes all execution time of sub-functions. exclusive time/self time The time it takes for the function to execute itself, excluding subtree execution time. wall time elapsed time or wall clock time. cpu time user time + kernel time inclusive cpu includes the cpu occupied by sub-functions together exclusive cpu The cpu occupied by the function itself

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

See all articles