Home > Backend Development > PHP Tutorial > [Transfer] Install PHP performance testing tool xhprof for Windows Apache 2.2 PHP 5.3, performance testing xhprof_PHP tutorial

[Transfer] Install PHP performance testing tool xhprof for Windows Apache 2.2 PHP 5.3, performance testing xhprof_PHP tutorial

WBOY
Release: 2016-07-12 09:07:18
Original
1098 people have browsed it

[Transfer] Install PHP performance testing tool xhprof for Windows Apache 2.2 PHP 5.3, performance test xhprof

Original link: http://blog.snsgou.com/post-816 .html

1. Download XHProf

Go here http://dev.freshsite.pl/php-extensions/xhprof.html to download the Windows version of XHProf. I choose to download it here

XHProf 0.10.3 for PHP 5.3 vc9 and xhprof_html

2. Install XHProf

Copy the xhprof_0.10.3_php53_vc9.dll in the compressed package to the PHP ext directory, and then add the configuration to 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"
Copy after login

 

3. Use XHProf

Extract xhprof_html.zip to the root directory of the website you want to test. For example, I placed it under /public/xhprof/windows in the website directory.

Test file:

<?php
function bar($x)
{
	if ($x > 0)
	{
		bar($x - 1);
	}
}

function foo()
{
	for ($idx = 0; $idx < 5; $idx++)
	{
		bar($idx);
		$x = strlen("abc");
	}
}

// 启动xhprof
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);

// 调用foo函数,也是我们要分析的函数
foo();

// 停止xhprof

$xhprof_data = xhprof_disable();

// 取得统计数据
//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";

// 保存统计数据,生成统计ID和source名称
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo"); // source名称是xhprof_foo

// 查看统计信息
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>";
Copy after login

 

When clicking the link "[View Full Callgraph]", an error will be reported:

<p>failed to execute cmd: " dot -Tpng"</p>
Copy after login

So you also need to download the graphics tool Graphviz.

4. Download Graphviz

Go here http://www.graphviz.org/Download_windows.php to download the Windows version of Graphviz. I choose to download it here

graphviz-2.38.zip

5. Install Graphviz

After decompression, copy Graphviz to a directory, such as d:/PHP/xhprof/graphviz-2.38/

6. Configure Graphviz

Find the config.php file under the above mentioned website directory /public/xhprof/windows/ and adjust it as follows:

<?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');
define('DOT_BINARY', 'd:/PHP/xhprof/graphviz-2.38/release/bin/dot.exe');
Copy after login

Click the link again [View Full Callgraph], and a long-awaited rendering comes out:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1061615.htmlTechArticle[Transfer] Install PHP performance testing tool xhprof for Windows Apache 2.2 PHP 5.3, performance test xhprof Original link: http: //blog.snsgou.com/post-816.html 1. Download XHProf herehtt...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template