PHP Conference Japan 2024

示例

示例 #1 带可选 GUI 的 Xhprof 示例

此示例启动和停止分析器,然后使用捆绑的 GUI 界面保存和解析结果。换句话说,扩展本身的代码在调用 xhprof_disable() 处结束。

<?php
xhprof_enable
(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);

for (
$i = 0; $i <= 1000; $i++) {
$a = $i * $i;
}

$xhprof_data = xhprof_disable();

$XHPROF_ROOT = "/tools/xhprof/";
include_once
$XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once
$XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";

$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_testing");

echo
"https://127.0.0.1/xhprof/xhprof_html/index.php?run={$run_id}&source=xhprof_testing\n";

?>

以上示例将输出类似以下内容

https://127.0.0.1/xhprof/xhprof_html/index.php?run=t11_4bdf44d21121f&source=xhprof_testing
添加注释

用户贡献的注释

此页面没有用户贡献的注释。
To Top