Original link: http://blog.snsgou.com/post-816.html
1. Download Xhprof
Here http://dev.freshsite.pl/php-extensions/xhprof.html download the Windows version of Xhprof, I choose here to download
Xhprof 0.10.3 for PHP 5.3 vc9 and xhprof_html
2, Installation Xhprof
Copy the Xhprof_0.10.3_php53_vc9.dll in the compressed package to the PHP ext directory, then add the configuration in the php.ini configuration (don't forget to create the corresponding folder)
[Xhprof]extension=xhprof_0.10.3_php53_vc9.dll; Directory used by default implementation of the Ixhprofruns; Interface (namely, the Xhprofruns_default Class) for storing; Xhprof runs.xhprof.output_dir= "D:/php/xhprof/log"
3. Using Xhprof
unzip the xhprof_html.zip to the root directory of the Web site you want to test, as I put it under the/public/xhprof/windows of the site directory.
Test file:
<?phpfunction Bar ($x) {if ($x > 0) {bar ($x-1);}} function foo () {for ($idx = 0; $idx < 5; $idx + +) {bar ($IDX); $x = strlen ("abc");} Start xhprofxhprof_enable (xhprof_flags_cpu + xhprof_flags_memory);//Call the Foo function, which is also the function foo () we want to parse;//Stop Xhprof$xhprof_data = Xhprof_disable ();//Get Statistical data//print_r ($xhprof _data); $os = ' windows '; $XHPROF _root = DirName (__file__). '/public/xhprof/'. $os, Include_once $XHPROF _root. "/xhprof_lib/utils/xhprof_lib.php"; include_once $XHPROF _root. "/xhprof_lib/utils/xhprof_runs.php";//save statistics, generate statistic ID and source name $xhprof_runs = new Xhprofruns_default (); $run _id = $ Xhprof_runs->save_run ($xhprof _data, "Xhprof_foo"); The source name is xhprof_foo//view statistics echo "<div style= ' margin:50px auto; padding:10px; width:92px; font-size:16px; Background: #ff0000; ' ><a style= ' color: #ffff00; ' href= '/public/xhprof/'. $os. "/xhprof_html/index.php?run=". $run _id. "&source=xhprof_foo ' target= ' _blank ' >xhprof view</a></div>";
When clicking on the link "[View full CallGraph]", an error will be added:
Failed to execute cmd: "Dot-tpng"
So you also need to download the graphical tools Graphviz.
4. Download Graphviz
Here http://www.graphviz.org/Download_windows.php download the Windows version of Graphviz, I choose here to download
Graphviz-2.38.zip
5, installation Graphviz
After extracting, copy the Graphviz to a directory, such as d:/php/xhprof/graphviz-2.38/
6, Configuration Graphviz
Locate the config.php file under the above mentioned site Directory/public/xhprof/windows/ , and adjust the following:
<?php/** * Set The absolute paths on your system */define (' Error_file ', ' d:/php/xhprof/log/xhprof_dot_errfile.log '); Define (' Tmp_directory ', ' d:/php/xhprof/tmp ');d efine (' dot_binary ', ' d:/php/xhprof/graphviz-2.38/release/bin/ Dot.exe ');
Re-click on the link [View full CallGraph], a long awaited out:
"Go" to Windows + Apache 2.2 + PHP 5.3 Install PHP Performance test Tool xhprof