Xhprof Examples

예제 #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