PHP7에서 xhprof 성능 분석 도구 설치 및 사용에 대한 그래픽 코드 튜토리얼

黄舟
풀어 주다: 2023-03-14 20:26:02
원래의
3016명이 탐색했습니다.


xhprof

cd xhprof/extension/
phpize
./configure 
makemake install
로그인 후 복사

를 설치한 후 /etc/php.ini에

extension=xhprof.so
로그인 후 복사

를 적절하게 추가하세요. github에서 복제한 파일의 example 디렉터리에서 직접 예제를 실행하시면 됩니다

출력은 다음과 같습니다

php -m | grep xhprof
로그인 후 복사

그런 다음 ?run=592567308784c&source=xhprof_foo

Visit

Array
(    [main()] => Array        (            [ct] => 1            [wt] => 9        ))
---------------Assuming you have set up the http based UI for 
XHProf at some address, you can view run at 
http://<xhprof-ui-address>/index.php?run=592567308784c&source=xhprof_foo
---------------
로그인 후 복사

를 복사하면 출력을 볼 수 있습니다

성능 분석 그림을 보려면 중간에 있는 전체 호출 그래프 보기를 클릭하세요

오류 보고

xhprof_html/index.php?run=592567308784c&source=xhprof_foo
로그인 후 복사
failed to execute cmd:" dot -Tpng". stderr:sh: dot:command not found。
로그인 후 복사
PHP7에서 xhprof 성능 분석 도구 설치 및 사용에 대한 그래픽 코드 튜토리얼변화에 적응

예를 들어 프레임워크의 성능 분석과 같은 자신의 프로젝트를 테스트하려는 경우입니다.

xhprof_lib/utils/ 아래의 두 파일

xhprof_lib.php 및 xhprof_runs.php를 항목 파일과 동일한 디렉터리에 복사한 다음 항목 파일 끝에

//解决方案yum install graphviz
로그인 후 복사

add

// start profiling
xhprof_enable();
로그인 후 복사

를 추가하여 위의 내용을 가져옵니다. url이 표시되면

// stop profiler
$xhprof_data = xhprof_disable();

// display raw xhprof data for the profiler run
print_r($xhprof_data);


include_once "xhprof_lib.php";
include_once "xhprof_runs.php";

// save raw data for this profiler run using default
// implementation of iXHProfRuns.
$xhprof_runs = new XHProfRuns_Default();

// save the run under a namespace "xhprof_foo"
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");

echo "---------------\n".
     "Assuming you have set up the http based UI for \n".
     "XHProf at some address, you can view run at \n".
     "http://<xhprof-ui-address>/index.php?run=$run_id&source=xhprof_foo\n".
     "---------------\n";
로그인 후 복사

를 다시 방문하여 아래 페이지를 확인하세요

사진 보기

PHP7에서 xhprof 성능 분석 도구 설치 및 사용에 대한 그래픽 코드 튜토리얼

사진에서 빨간색 부분은 성능이 낮고 시간 소모가 더 긴 부분입니다. 시스템 코드를 최적화하기 위해 빨간색으로 표시된 기능은 무엇입니까

Supplement

http://***/xhprof_html/index.php?run=*****&source=xhprof_foo
로그인 후 복사

위 내용은 PHP7에서 xhprof 성능 분석 도구 설치 및 사용에 대한 그래픽 코드 튜토리얼의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!