PHP程式效能剖析(使用 xdebug 和 webgrind)

來源:互聯網
上載者:User
PHP程式效能剖析(使用 xdebug 和 webgrind)

PHP 程式上線前我們一般需要做一個效能剖析,看看程式花費的時間到底在哪裡。一個最簡單的方法是使用 XDebug 的 profile 功能。XDebug 可以配置對相應PHP程式執行輸出 cachegrind 格式的檔案,我們之後用 分析軟體去分析這個輸出檔案,就可以看到效能的結果了。

首先:配置 XDebug

zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so   xdebug.profiler_enable=0   ## 使用這個選項,我們只在需要做剖析的時間才激發這個剖析操作,   ## 使用方法 http://localhost/workspace/article.sitetuan/?XDEBUG_PROFILE   xdebug.profiler_enable_trigger=1   ## 剖析檔案放到 /tmp 目錄下   xdebug.profiler_output_dir="/tmp/xdebug.profile/"

然後下載 webgrind 程式(Google 自己搜尋),直接接壓縮到 apache 的目錄下,一般是 /var/www 目錄

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.