Ref/xhprof-Phpdoc专题
xhprof_disable
停止 xhprof 分析器
说明
array <span class="methodname">xhprof_disable ( <span class="methodparam">void )
停止性能分析,并返回此次运行的 xhprof 数据。
参数
此函数没有参数。
返回值
本次运行的 array 类型的 xhprof 数据。
范例
示例 #1 xhprof_disable 范例
<?php
xhprof_enable();
$foo = strlen("foo bar");
$xhprof_data = xhprof_disable();
print_r($xhprof_data);
?>
以上例程的输出类似于:
Array
(
[main()==>strlen] => Array
(
[ct] => 1
[wt] => 279
)
[main()==>xhprof_disable] => Array
(
[ct] => 1
[wt] => 9
)
[main()] => Array
(
[ct] => 1
[wt] => 610
)
)
xhprof_enable
启动 xhprof 性能分析器
说明
void <span
class="methodname">xhprof_enable ([ <span
class="methodparam">int $flags<span
class="initializer"> = 0 [, <span
class="methodparam">array $options
]] )
启动 xhprof 进行性能分析。
参数
flags
分析添加额外信息的可选标记。 关于此标记的更多信息参见
XHprof 常量,例如,
XHPROF_FLAGS_MEMORY 可以开启内存的分析。
options
array 的可选选项,就是通过传递
'ignored_functions' 选项来忽略性能分析中的某些函数。
返回值
null
更新日志
| 版本 | 说明 |
|---|---|
| 0.9.2 | 添加可选的 options 参数。 |
范例
示例 #1 xhprof_enable 范例
<?php
// 1. elapsed time + memory + CPU profiling; and ignore built-in (internal) functions
xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
// 2. elapsed time profiling; ignore call_user_func* during profiling
xhprof_enable(
0,
array('ignored_functions' => array('call_user_func',
'call_user_func_array')));
// 3. elapsed time + memory profiling; ignore call_user_func* during profiling
xhprof_enable(
XHPROF_FLAGS_MEMORY,
array('ignored_functions' => array('call_user_func',
'call_user_func_array')));
?>
参见
- xhprof_disable
- xhprof_sample_enable
- memory_get_usage
- getrusage
xhprof_sample_disable
停止 xhprof 性能采样分析器
说明
array <span class="methodname">xhprof_sample_disable ( <span class="methodparam">void )
停止采样模式的 xhprof 分析器。
参数
此函数没有参数。
返回值
本次运行的xhprof采样数据,array 类型。
范例
示例 #1 xhprof_sample_disable 范例
<?php
xhprof_sample_enable();
for ($i = 0; $i <= 10000; $i++) {
$a = strlen($i);
$b = $i * $a;
$c = rand();
}
$xhprof_data = xhprof_sample_disable();
print_r($xhprof_data);
?>
以上例程的输出类似于:
Array
(
[1272935300.800000] => main()
[1272935300.900000] => main()
)
xhprof_sample_enable
以采样模式启动 XHProf 性能分析
说明
void <span class="methodname">xhprof_sample_enable ( <span class="methodparam">void )
xhprof_enable 的更轻量的版本,以采样模式开始性能分析。 抽样的间隔为 0.1 秒,样本记录了完整的函数调用堆栈。 主要使用的情况是以较低的性能开销来进行性能监控和诊断。
参数
此函数没有参数。
返回值
null
参见
- xhprof_sample_disable
- xhprof_enable
- memory_get_usage
- getrusage
目录
- xhprof_disable — 停止 xhprof 分析器
- xhprof_enable — 启动 xhprof 性能分析器
- xhprof_sample_disable — 停止 xhprof 性能采样分析器
- xhprof_sample_enable — 以采样模式启动 XHProf 性能分析