Php5.3XHProf performance test {Xhprof}
XhProf is a hierarchical PHP performance analysis tool that reports function-level requests and various metrics, including blocking time, CPU time, and memory usage.
[Situation]
The combination of Apache + php with the above two applications is common in Windows. it is generally used to organize the development environment, debug the environment, or test the environment. of course, many of them are used in the production environment, for me, I used them for development. because I am used to development under Windows, even though I have set up a development platform based on Linux virtual machines, I can still use it, however, it is impossible to leave the Windows environment.
I have been developing and debugging in eclipse + xdebug mode. I haven't encountered many problems and the development is smooth. However, when I tested a page yesterday, it is found that php has a lock-like phenomenon, that is, after the page is executed, php-cgi has been hanging in the process, neither cpu consumption nor memory growth, the website is not generated, and I cannot solve it. I did not find any obvious bottleneck when I checked and debugged the code carefully. In addition, I tested it on my 6-core computer, the file system is also normal, and locking becomes a strange thing. I am using Apache_1.3.37-Win32 + php-5.2.6-Win32 + Xdebug-2.1.2 version debugging, found that in the debugging process, the entire eclipse is in a non-responsive state, it seems that this locking has conductivity, therefore, debugging has been unable to proceed. because I have written a lot of code, I am a little tired and have not thought about the specific reason. I have to wait for a while.
When searching, I accidentally discovered the Xhprof tool. after reading some blogs, I found that this tool can analyze program performance. The value may be rough and function-based, but it is very intuitive and clear, and very interested, so I suspended the development just now and studied this thing.
[Process]
I have referenced several blog posts, and they are all based on the Linux version. I didn't find a Windows-based introduction. I can't switch to Linux for development at all? So search again, found that a foreign site provides a compiled Xhprof, but the version is based on the php-5.3.3-Win32 version, the code is based on Xhprof version 0.9.2, huh, it seems that some people come along with me, but there are very few search results, almost none of which are Chinese, and there are only a few results in foreign languages.
Xhprof for windows was downloaded from the foreign language site, and related xhprof code and related page documents were downloaded from the original facebook release site. because xhprof is compiled based on php5.3.3, you also need to prepare php5.3.3 and directly go to php.net to pull a vc6 thread security version.
Apache is ready-made, so the original http. conf: introduce php5.3.3 to apache in cgi mode. After debugging, the integration is smooth. phpinfo is running normally, and xdebug is running properly. now, we are ready to join xhprof.
Install xhprof for windows directly, and add the Debugging Page and code to the page to be tested.
[Step]
First Download xhprof for windows version, this does not have to say, address: http://www.benjamin-carl.de /? Download = XHProf-0.10.0-PHP-5.3.3-VC6-x86-TS, http://pan.baidu.com/share/link? Unzip id = 239782 & uk = 337775431 after the zip file is decompressed, it is a dll file, which can be directly put into the php ext directory, as shown in 1:
Then we need to place the two subdirectories of xhprof that contain the debug output page. here I chose to directly place them in the root directory of my website's publishing location, that is, in the default directory of apache htdocs, the htdocs here is transferred to another development USB flash drive to facilitate code compilation in different places, as shown in figure 2, the figure below shows three folders in total: xhprof_html, xhprof_lib, and xprof_log. xhprof_html and xhprof_lib are obtained from the downloaded xhprof source code file package, where the package is located: Release.
[Xhprof]
Extension = php_xhprof.dll
; Directory used by default implementation of the iXHProfRuns
; Interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
Xhprof. output_dir = "M:/htdocs/xhprof_log"
"Prompt: xhprof. output_dir = This is used to set the storage location of the performance analysis data. I should set it to M:/htdocs/xhprof_log, that is, the directory location described above"
After successful addition, restart Apache to check whether the phpinfo () information contains the xhprof section. If yes, the installation is successful. the following message is displayed: php running in cgi mode modified php. after ini, you can directly run phpinfo () to view the results without restarting Apache. The result is as follows: