InCodeXdebug has been used for breakpoint debugging. I recently learned that xdebug can also perform Performance Analysis on PHP Web code. The following describes how to use it.
Download xdebug at http://www.xdebug.com/download.php. Note that the downloaded xdebug version must match your PHP version. Otherwise, the system will crash. If the system crashes, download another version. I downloaded the Windows version for PHP 5.2.8 After the download is complete, I change the file name to "php_xdebug.dll ".
Then you need to place php_xdebug.dll In the ext record of PHP. On our local machine, it is "C: \ Wamp \ bin \ PHP ". 5.2.8 \ Ext ". I installed wampserver in the C root directory.
Next, modify the php. ini file. Add the following content at the end of the file:
[Xdebug]
Zend_extension_ts = "C:/Wamp/bin/PHP 5.2.8 /EXT/php_xdebug.dll"
Xdebug. auto_trace = 1
Xdebug. collect_params = 1
Xdebug. collect_return = 1
Xdebug. trace_output_dir = "D:/temp/xdebug"
Xdebug. profiler_enable = 1
Xdebug. profiler_output_dir = "D:/temp/xdebug"
Xdebug. profiler_output_name = "cachegrind. Out. % t"
Xdebug. remote_enable = 1
Xdebug. remote_handler = dbgp
Xdebug. remote_host = localhost
Xdebug. remote_port = 9000
The "xdebug. profiler" option tells xdebug to analyze the performance of PHP code. The analysis result is output to the "D: \ temp \ xdebug" directory. The file is named "cachegrind. Out. timestamp.
Finally, restart the Apache server. If there is no error during the restart process, you can do it. You can see the xdebug configuration information through the phpinfo function, as shown in 1:
(Figure 1)
We can try it out by requesting a local page. Two files are generated in the D: \ temp \ xdebug directory:
- Cachegrind. out.1277560600
- Trace.3495983249.xt
"1277560600" is the timestamp. This value is "% t" in "xdebug. profiler_output_name =" cachegrind. Out. % t ". Both files are text files. You can view the content in the files in notepad. But unfortunately, the content here is hard to understand. But we are also lucky to have tools to help us understand these two files. Http://www.xdebug.com/docs/profilerthis address introduces three analysis tools: kcachegrind (for Linux), wincachegrind (for Windows), and webgrind (for Web pages ).
I chose webgrind. Go to http://code.google.com/p/webgrind/download, and then decompress it to the apachewebsite root directory (that is, under the htdocs directory). Basically, no configuration needs to be modified. Run http: // 127.0.0.1/webgrind to view performance analysis records. 2:
(Figure 2)