XDebug + Wincachegrind on Windows
Xdebug helps to debug and benchmark your code.
Among other things, this will help you to write more useful bug reports on drupal.org.
To start debugging on windows, a decent solution is XDebug + Wincachegrind.
For other ways to work with xdebug, see
Set up xdebug, and make it create log files in a folder of your choice.
Go to http://www.xdebug.org/download.php, download the php_xdebug.dll that fits your php version, and put it in your php extensions folder.
You will have to do some setup in your php.ini (and restart apache when it's done).
You can adapt this code and add it at the end of your php.ini (suggestions are welcome):
[PHP_XDEBUG]
zend_extension_ts="C:/php-5-2/ext/php_xdebug.dll"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="D:/php-5-2/xdebug-log"
xdebug.profiler_output_name="request-%R---time-%t.cachegrind"
xdebug.collect_params = 3
You can find instructions in the xdebug manual,
http://www.xdebug.org/docs/all_settings.
xdebug has to be activated as a zend_extension_ts, not just as a normal extension. As an implication, you need to specify the complete path, not just relative to the extension_dir.
You should make sure the folder to save the files does exist, otherwise you will get errors.
If you are on windows, it's nice to have a common file ending for these files, so you can associate them with a program (".cachegrind" is just an example). If that doesn't work for you, use the default setting.
Restart Apache.
You can now run any PHP request and should see a file appear in the specified directory.
If it doesn't work, you should find some error reports into your apache error.log file.
Typical issues with xdebug
If you find that Xdebug crashes your server:
- make sure you have the correct version that fits your PHP version (non-thread-safe vs thread-safe etc).
- search the web, file a bug report on xdebug.org, etc
- write a comment on this page
Read the log files using Wincachegrind
This can be wincachegrind on windows, or kcachegrind on linux (google is your friend), or what else you might find on the web.
http://sourceforge.net/projects/wincachegrind/
Issues with wincachegrind
There is a known bug in wincachegrind that makes all reported times appear as 1/10 of the actual milliseconds. So, if wincachegrind shows a function with 300ms execution time, the true execution time is 3.000 ms = 3 seconds.
