RequirementsTo run webgrind you need a webserver with PHP 5 installed. Webgrind uses json_encode that is available from PHP 5.2 or as a PECL extension before that. Xdebug does the actual profiling so that should be installed first (http://www.xdebug.org/docs/install). Then add the following to your php.ini file: Always profile scripts with xdebug: xdebug.profiler_enable = 1 Alternatively, enable profiling with GET/POST parameter XDEBUG_PROFILE, e.g. http://localhost/samplepage.php?XDEBUG_PROFILE: xdebug.profiler_enable_trigger = 1 Please refer to the Xdebug manual for further configuration settings: http://www.xdebug.org/docs/all_settings Installation
Installing webgrind on production servers is highly discouraged as it might allow access to sensitive files. ConfigurationWebgrind can be configured by editing the config.php file in the webgrind directory, but should work with default settings provided Xdebug is installed and configured correctly.
Further configuration options are described in the config.php file itself. |
> Start using webgrind with your browser of choice. <
How ?
Maybe the authors are a little too close to it, but for the uninitiated a little elaboration and an example would be most helpful ... and maybe contribute to more widespread use.
does it requires specific Xcode settings? I can select cachegrind file but I got always blank page on output.
How do you use it???? why is it such a secret?? I can't find help on using this anywhere
You need to get xdebug to generate cachegrind files first. Once you can get Xdebug to generate cache grinds, you can look at them. For me it found the grind files automatically.
This worked out of the box for me on osx leopard using mamp. My xdebug cachegrind files are in '/xdebug-profiling' and I set that folder in the webgrind config file as the 'storageDir'. I'm not sure if this is needed though.
Problems like the above may be caused by a php version lower than 5.2 and/or the lack of json_encode support...
And for the people who don't get the 'start using webgrind with your browser of choice': if you put your webgrind folder in your server root, then point your browser to http://localhost/webgrind, select a file in the dropdown menu in the top right corner and click 'update' and you're done. All the nice stats should show up in your browser :)
To enable xdebug profiler you need to put "xdebug.profiler_enable=1" to your php.ini.
In MAMP, I first had to disable the zend optimizer ... not sure if that was enabled out of the box or not because my MAMP build has gotten pretty hacked up in the past year since MAMP 1.7 came out.
You need a .htaccess file in the directory for webgrind and where your app is with this:
The problem I found was that webgrind assumes this is set for its own directory and that the php values for profiler_output_dir and profiler_output_name are set. The script needs an easy override command for the output directory and output name format in the config.php file.
I dont know how to use it.
Could you post a more detailed installation instructions please ?
Unable to make it work on a windows XAMPP install. The Xdebug trace shows that webgrind finds the profiling dumps and prepares to show them, but the web page doesn't have anything on it...
Just posted an article on installing and configuring webgrind here: http://www.chrisabernethy.com/php-profiling-xdebug-webgrind/
I found that one of the issues is making sure to specify a value for xdebug.profiler_output_name that wouldn't cause the file to be overwritten each time you serve a page from the same Apache process (the value defaults to using PID as a unique identifier).
Hello, I try to make it works on a debian server and i just achieve to profile the code of webgrind itself, how can i profile other script which are located at the same root level directory ... ?
thx
Hi, I made it to work with the following configuration in both /apache/bin/php.ini AND /php/php.ini:
For full guide on how to install webgrind + xdebug go here: http://anantgarg.com/2009/03/10/php-xdebug-webgrind-installation/
In wich section of php.ini must be written this line : xdebug.profiler_enable = 1 At the end of the php.ini file ?
@angelo.rigo:
It doesn't matter where in the php.ini file you put the xdebug enabling line. Please refer to the documentation for xdebug for further instructions on how to set it up: http://xdebug.org/docs/
Is xdebug listed on the phpinfo function ? or the way i can see the extension is enabled is looking at the php.ini file ?
@angelo.rigo:
Yes, the xdebug extension will appear in the output of phpinfo() as a separate section with version information.
>The Xdebug trace shows that webgrind finds the profiling dumps and prepares to >show them, but the web page doesn't have anything on it...
Please note that webgrind (at least v 1.0) needs function "json_encode". It is a built-in function since PHP >= 5.2.0. Otherwise you shoud install it manually: http://pecl.php.net/package/json For example, use "pecl install json" and it will produce json.so module
Couldn't get this going until I used
xdebug.profiler_output_name = "cachegrind.out.%t.%p"
Looks nice otherwise! :)
SO, keep in mind that if you have changed the xdebug.profile_output_name to not include a pid then webgrind will not find your profiles. The reason is because it excludes its own cachegrind profiles on purpose to avoid infinite loop.
In order to display results by webgrind I had to let xdebug generate the profiler file names by itself by removing (commenting out) the "xdebug.profiler_output_name" value in my php.ini. That way xdebug generated it's default profiling results file names like "cachegrind.out.3200" etc. So basically thetrippy's comment was helpful because webgrind refused to read custom defined profiling results file names although WebCacheGrind? didn't have such problems.
Also I have to agree that webgrind is not well documented, especially the installation part which simply misses to explain some important parts of the installation process.
can you make install tutorial for xampp on ubuntu
If you are using a .htaccess file file for custom output file-naming or a custom profile directory, (ie. not set globally in php.ini) you will need to modify the xDebugOutputFormat() function and the xdebugOutputDir() function to return the correct paths as they check the php.ini file for a value first, overriding whatever is in your Webgrind_Config?.
I've installed successfully. But there will render no files! I can't see any error. cachegrind.out... Files are there, Filerights are all ok, apache Log gives me no error! I have no Idea! In the Dropdown List "Auto (newest)" are no files to select! I spend over 2 hour! ....... Maybe there is an angel who can help me!
@bruno.ziegler: Have you verified that webgrind is looking in the correct directory for the cachegrind output files? Also check that the format specifier matches that of the filenames.
Loving Webgrind. Thank you, developers.
I've written up a Webgrind install tutorial for MAMP on OS X that includes a quick intro to the Webgrind UI.
Note that you need to click the 'update' button on the top right after selecting your cachegrind fine (or leave it at Auto) from the drop down list.
Refreshing the initial page won't do anything.
I thought it wasn't working because I pressed F5 to reload the webgrind screen, but in fact it wanted me to click Update at the top right.
Anyone get empty output files? I have cachegrind files being written where I said and when I run xdebug (i can debug and step through my php scripts as well, something like komodo ide will allow me to step in/out/over) but the files it's writing to disk are just empty (0 bytes). Any ideas? Thanks
Got it. No sooner do I give up and ask after hours of trying do I spend another 5 minutes and get it. Seemingly just: xdebug.profiler_append=1 made it work. Now not only are the files full of data, they also have the script name rather than Unknown! (cachegrind.out.127.... Don't know why, but that made it work.
I had some experience to make webgrind show the list of files. The reason was that debugger files were located in /var/www/xdebug and webgrind was installed in /var/www/webgrind. So, the virtual host with the root /var/www/webgrind had php open_basedir restriction. To make webrind available to see the profiler output set php_admin_value open_basedir none or something like php_admin_value open_basedir "/var/www/webgrind-server:/var/www/profiler-output"
Ostensibly useful product rendered useless by inadequate installation information (or inadequate code?).
I found today that having the %s script name piece in the profiler_output_name file format mask would result in webgrind not seeing any of the cachegrind files that I verified were in my profiler_output_dir.
I've get it to work on a PHP 5.1.6 server w/o json_enconde. I downloaded (and required it on config.php) jsonwrapper (http://www.boutell.com/scripts/jsonwrapper.html). Hope it helps!
This should be a great product. But the installation process is poor and only gaves you frustration. You (creator/developer) really need to provide more complete information on the installation process. Or make the installation more simple.
The all "auto-detection" process for directories and files pattern doesn't work. Googling everywhere on every forum i found something like 60 posts (per forum) with frustrated people that can't make it work.
I finally make it work, following three different tutorials and honestly... I don't known how. Great product anyway.
This is a constructive critic, i'm a developer and i kown the cost to produce a nice product (even open source).
If you installed WAMPP, go to php.ini At the bottom of the file you will find
xdebug? xdebug.remote_enable = off xdebug.profiler_enable = off xdebug.profiler_enable_trigger = off xdebug.profiler_output_name = cachegrind.out.%t.%p xdebug.profiler_output_dir = "c:/wamp/tmp"
Change it to this: xdebug.remote_enable = 1 xdebug.profiler_enable = 1
Hope this help a lot of you.
To use webgrind you have to place cachegrind file into configured directory ($profilerDir) or change directory in config ;) Than you'll find your files in webgrind selector on top of page. And all you have to do now is to push "update"
If you are seeing the xdebug output files in the file selector but are getting the dreaded "Select a cachegrind file above" message and nothing else when you click "Update" instead of the expected results then it probably means that webgrind is erroring out during the ajax call. (You can confirm this using the Console in Firebug.)
Solution that worked for me: make the webgrind and webgrind/tmp directories writable by all processes. No more ajax errors, and the selected file is parsed and displayed successfully.
Hi there I am unable to select path of the file after opening the http://localhost/webgrind/ . I can select from first and dropdown. but 2nd one is not working i looks like it dose not work. when i click on dropdown button it shows Auto(newest) but i cannot chang it to my file or directory.
In WAMP 2.1 http://www.wampserver.com/ installation under Win7 (latest as of a couple days ago), I needed only to change Apache php.ini, set:
Changes in php php.ini seemed to be irrelevant for me.
Who don't any clue how to use it, then it's better to use KCacheGrind (http://kcachegrind.sf.net/) or WinCacheGrind? (http://sourceforge.net/projects/wincachegrind) instead.
Also worth to read the Xdebug documentation about profiling setup: http://www.xdebug.org/docs/profiler. Don't forget, this project is about viewing profiler data, not for profiling. So the documentation should not contain the entire profiling process.
how to use it