15

I just installed wamp and the latest version comes with webgrind, but i cannot figure out how it works.It says

Select a cachegrind file above

And thats all.

jokkedk
  • 2,390
  • 2
  • 17
  • 21
andrei
  • 8,252
  • 14
  • 51
  • 66

5 Answers5

16

Webgrind is a parser/viewer for a profiling file format called cachegrind. The PHP extension Xdebug can (among other very useful things) generate these. For webgrind to work, Xdebug needs to be installed and enabled.

  1. Make sure Xdebug is installed and working (see the Xdebug docs for info on how to do that)
  2. Have Xdebug generate a profiling report by requesting a local PHP file
  3. Load webgrind in the browser and select a file in the popup-menu at the top
  4. Press update, and hopefully everything should work

The wiki on Google Code has more on configuring webgrind.

Synetech
  • 9,643
  • 9
  • 64
  • 96
jokkedk
  • 2,390
  • 2
  • 17
  • 21
  • To me, the last step wasn't producing anything (there was no change on screen), but webgrind was actually making the update call. After checking, it turned out that local webserver was spitting out a bunch of PHP notices (webgrind's issues), which were breaking the page-behavior. I added a `php_flag error_reporting E_NONE` into the .htaccess file, in the webgrind folder and it all worked! – userfuser Sep 15 '21 at 08:55
14

1) Download XDebug from their download page.

2) Put all DLL files in your PHP extension directory: C:\wamp\bin\php\php5.x.x\ext

3) Add the following line in your php.ini file located in C:\wamp\bin\php\php5.x.x:

zend_extension = c:\wamp\bin\php\php5.3.0\ext\php_xdebug-2.1.0-5.3-vc6.dll

4) Add also the following section to your php.ini (search for the [xdebug] section first to make sure it does not exist yet):

[xdebug]
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "c:\wamp\www\webgrind\tmp"
xdebug.profiler_output_name = cachegrind.out.%t.%p

5) Restart Wamp and verify that the extension was loaded. To do so, add a file pi.php in C:\wamp\www\ and put the following code in it:

<?php
    phpinfo();
?>

6) Check the output by opening your browser at http://localhost/pi.php and search for XDebug.

7) Download Webgrind from their download page and extract in in your www folder.

8) Edit the config.phpfile located in C:\wamp\www\webgrind\ to change the storage directories:

static $storageDir = 'c:\wamp\www\webgrind\tmp';
static $profilerDir = 'c:\wamp\www\webgrind\tmp';

9) In the Webgrind directory where you have extracted the code, add an .htaccess file and put this content in it to avoid webgrind from profiling itself:

php_flag xdebug.profiler_enable 0

10) Rerun the http://localhost/pi.php script to generate some profiling data.

11) Open your browser with http://localhost/webgrind to display the results. Do not forget to click the Update button!

This answer is based on an answer provided by Jacob Moen. You can view the original source here.

bantya
  • 576
  • 11
  • 23
Maxime
  • 8,645
  • 5
  • 50
  • 53
  • And what happens if that blog goes away or that post gets moved? Link-only questions have a limited life-span on the Internet; better to list the relevant points here like jokkedk did (or post a link as a comment instead of an “answer”). – Synetech Nov 19 '13 at 21:24
  • Hope you'll appreciate the effort! ;-) – Maxime Nov 21 '13 at 00:55
  • Personally, sort of. I don’t currently use Xdebug or webgrind, so it means little to me (though I am looking into it at the moment), but others will definitely appreciate it, especially in the future when people come across your post—or cached/ripped copies of it—via a search engine, and the blog you linked to is no longer available. Either way, [link-only answers are really frowned upon](http://www.google.com/search?q=link+only+answers) for the reasons I just explained, so by improving your answer, it won’t get deleted or converted to a comment and in fact will get up-voted. `;-)` – Synetech Nov 21 '13 at 01:08
  • Make sure to specif the directory where the xdebug module is located. That can be a [stumbling point](http://stackoverflow.com/a/20111302/119540). – Synetech Nov 21 '13 at 02:27
0

It is good to watch if the application becomes SLOW, had problems with it because of the settings of Cachegrind.

Good luck!

My settings are Wamp 2.4, Apache 2.4, PHP 5.4 and MySQL 5.6

[Portugues pt_BR]

É bom prestar atenção se a aplicação se tornar LENTA, tive problemas com isso por causa das configurações do cachegrind.

Boa sorte!

Minhas configurações são Wamp 2.4, Apache 2.4, PHP 5.4 e MySQL 5.6

vandersondf
  • 839
  • 1
  • 9
  • 8
0

Update the PHP.INI with these parameters

  • xdebug.profiler_enable = 1
  • xdebug.profiler_enable_trigger = 1

RESTART ALL SERVICES

this should be work.

0

You don't have to do much....

I just edited the line to be

xdebug.profiler_enable = 1

Thats all buddy. Totally works!

Patrick Mutwiri
  • 1,301
  • 1
  • 12
  • 23