Xhprof php效能測試用具用法小結

來源:互聯網
上載者:User
Xhprof php效能測試工具用法小結

Xhprof 是facebook推出的輕量級的php效能分析工具,和Xdebug相比,XHProf更加易用和可控,尤其是產生流程圖和調試資料對比的功能很好很強大。 下面簡單介紹下Xhprof的安裝及使用。

1、安裝

可以從頁面 下載相應版本及瞭解各個版本依賴條件。 安裝前,先假設php的bin目錄是:/usr/local/php/bin

[root@localhost extension]# ln -s /usr/local/php/bin/phpize /usr/bin/phpize[root@localhost tool]# wget http://pecl.php.net/get/xhprof-0.9.2.tgz[root@localhost tool]# tar -zxvf xhprof-0.9.2.tgz [root@localhost tool]# cd xhprof-0.9.2/extension/[root@localhost tool]# ./configure --with-php-config=/usr/local/php/bin/php-config[root@localhost tool]# make[root@localhost tool]# make install

通過上面的操作,如果運氣不是非常糟糕的話,你應該看到類似這樣的提示:Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

進入到php擴充庫目錄/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/ ,你將看到xhprof.so 共用庫檔案。

2、配置

在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=xhprof.output_dir=/tmp/xhprof

重啟下php,就可以在使用xhprof了。

3、拷貝檔案

把xhprof-0.9.2目錄下的目錄xhprof_html 和 xhprof_lib 下的所有檔案拷貝到你網站的主目錄下,假設網站主目錄:/opt/wordpress

[root@localhost xhprof-0.9.2]# cp -R xhprof_* /opt/wordpress

4、使用

參考下面的解釋說明:

save_run($data, "xhprof"); //查看運行結果的url//run的值來源於save_run的傳回值//source值來源於save_run的第二個參數                                 //www.abc.com 需要用自己的網域名稱替換echo "http://www.abc.com/xhprof_html/index.php?run=".$run_id."&source=xhprof";

在瀏覽器中開啟輸出的url,及可看到相關的效能資訊。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.