Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

Webgrind: A Web Frontend for Xdebug

Xdebugにはプロファイラ機能があるわけですが、そのプロファイリングデータを表示するWebフロントエンドが今年のGoogle Summer of Codeに登録されてるようです。


My about page has mentioned a web based frontend for Xdebug for some time. The project has a name now: The idea for Webgrind, a spin on Valgrind, came from lack of profiling tools for PHP, particularly on OSX. Though it is possible to install kcachegrind on osx it seems overkill for many uses and is definitely not as easy as unzipping a folder to the webroot.

で、ダウンロードして試してみました。プロファイリング対象はPEAR::Date_Holidays_Driver_Japaneseのsample.phpで、

<?phpif (false) {

の部分を

<?phpif (true) {

にしたものです。
手順ですが、

  1. webgrindのアーカイブを適当なディレクトリに展開
  2. php.iniに「xdebug.profiler_enable=1」を追加
  3. sample.phpを実行
  4. webgrindから読み込む

な感じです。実際の動作は

をどうぞ。右上にある「update」ボタンを押すとプロファイリングデータが表示されます。
なお、大量のスクリプトをrequire/includeするプログラムの場合、プロファイリングデータがかなり大きくなるため表示が遅くなりがちので、webgrind画面の上にある「Show」の値を小さくした方が良さそうです。
まだまだ開発中みたいですが、最低限必要な機能は用意されてる感じです。最終的には、KCacheGrind入れられない場合とか、意地でもブラウザ上でやる場合などに使えるかも知れません。