成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Linux 下安裝PHP性能分析工具 xhprof 筆記

瀏覽:2日期:2022-09-14 10:14:40

為ECOS框架寫(xiě)了一個(gè)相關(guān)的APP應(yīng)用,前段時(shí)候要用xhprof來(lái)測(cè)試一下ECAE上的php的運(yùn)行效率又重新要安裝xhprof,本日志記錄下相關(guān)的過(guò)程,以便以后再次使用到。

編譯安裝

wget http://pecl.php.net/get/xhprof-0.9.2.tgztar zxf xhprof-0.9.2.tgzcd xhprof-0.9.2/extension/sudo phpize./configure --with-php-config=/usr/local/php/bin/php-configsudo makesudo make install

配置 php.ini

在php.ini里加入

[xhprof]extension=xhprof.so;; directory used by default implementation of the iXHProfRuns; interface (namely, the XHProfRuns_Default class) for storing; XHProf runs.;;xhprof.output_dir=<directory_for_storing_xhprof_runs>xhprof.output_dir=/tmp/xhprof

注:如果是64位系統(tǒng)需要將xhprof.so文件拷貝到相關(guān)的lib64的目錄下

將代碼加入到要測(cè)試的php當(dāng)中

<?pho// cpu:XHPROF_FLAGS_CPU 內(nèi)存:XHPROF_FLAGS_MEMORY// 如果兩個(gè)一起:XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORYxhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);// 要測(cè)試的php代碼$data = xhprof_disable(); //返回運(yùn)行數(shù)據(jù)// xhprof_lib在下載的包里存在這個(gè)目錄,記得將目錄包含到運(yùn)行的php代碼中include_once 'xhprof_lib/utils/xhprof_lib.php';include_once 'xhprof_lib/utils/xhprof_runs.php';$objXhprofRun = new XHProfRuns_Default();// 第一個(gè)參數(shù)j是xhprof_disable()函數(shù)返回的運(yùn)行信息// 第二個(gè)參數(shù)是自定義的命名空間字符串(任意字符串),// 返回運(yùn)行ID,用這個(gè)ID查看相關(guān)的運(yùn)行結(jié)果$run_id = $objXhprofRun->save_run($data, 'xhprof');var_dump($run_id);

查看運(yùn)行結(jié)果

將xhprof_lib&&xhprof_html相關(guān)目錄copy到可以訪問(wèn)到的地址訪問(wèn) xxx/xhprof_html/index.php?run=$run_id&source=bluefrog 就可經(jīng)看到你的php代碼運(yùn)行的相關(guān)情況

下面是一些參數(shù)說(shuō)明

Inclusive Time 包括子函數(shù)所有執(zhí)行時(shí)間。Exclusive Time/Self Time 函數(shù)執(zhí)行本身花費(fèi)的時(shí)間,不包括子樹(shù)執(zhí)行時(shí)間。Wall Time 花去了的時(shí)間或掛鐘時(shí)間。CPU Time 用戶耗的時(shí)間+內(nèi)核耗的時(shí)間Inclusive CPU 包括子函數(shù)一起所占用的CPUExclusive CPU 函數(shù)自身所占用的CPU

注:?需要使用ctype這個(gè)擴(kuò)展

標(biāo)簽: PHP
相關(guān)文章: