« 定義済み定数
Xhprof 関数 »

例

例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 "http://localhost/xhprof/xhprof_html/index.php?run={$run_id}&source=xhprof_testing\n";

?>

上の例の出力は、 たとえば以下のようになります。

http://localhost/xhprof/xhprof_html/index.php?run=t11_4bdf44d21121f&source=xhprof_testing
関連キーワード:
xhprof   Xhprof   runs   testing   disable   once   utils   localhost   index   定数   プロファイラ   開始   組み込み   パース   拡張   自身   コード   時点   enable   tools   XHProfRuns   Default   save
関連する関数・ページ:
ref.xhprof   function.xhprof-disable   function.xhprof-sample-disable   function.xhprof-sample-enable   function.xhprof-enable   xhprof.configuration