tags:

views:

67

answers:

4

Looking for some [freeware/opensource] tool in order to make it easy to profile a big php project on win32 platform. Need to find out which part of code is most time consuming. It's hard to manually put timing function for each function, loop...

+6  A: 

You'll want to install and configure Xdebug. It's sort of the de-facto standard PHP debugging and profiling tool.

WinCacheGrind can crunch the profiling output. It's a bit buggy, but it does the job.

zombat
You beat me twice!?!? curses!
SeanJA
Haha... it's like the Wild West of programming around here ;)
zombat
Thanks guys! WinCacheGrind is really buggy, tried to open multiple output files with no success. Tried also webgrind - but do I have to stop server every time I need to use webgrind with latest output file, so web server will release it? Or I'm doing something wrong...
Michael
I usually just copy the output files to a local machine to grind them there, otherwise the get overwritten on subsequent requests. They can be extremely large as well, so it's easier to crunch locally. Best bet is to have a local development copy of the app if you can.
zombat
For wincachegrind you have to make sure that the grind's filename is exactly as it expects otherwise you will not be able to grind it.
SeanJA
For parsing with webgrind you can add an htaccess file to your directory containing: `php_flag xdebug.profiler_enable 1``php_value xdebug.profiler_output_dir /full/path/to/save/grindfiles` `php_value xdebug.profiler_output_name cachegrind.out.%t.%p` to make sure that the cachegrind will only be done on that site/folder and not others (at least that is what the installation page says http://code.google.com/p/webgrind/wiki/Installation )
SeanJA
Also, instead of using cachegrind, you could use `xdebug_start_trace('c:\\trace');` and `xdebug_stop_trace();` (if omitted it will run until the end of the script. The trace will show up at `c:\trace.xt` (the extension is added automatically) and you can just read through the file to see what is going on (there are various settings you can change in your php.ini file as to the verbosity of the output.
SeanJA
+2  A: 

xdebug works quite well http://xdebug.org

Also wincachegrind is a good tool for looking through the profiler's output. http://sourceforge.net/projects/wincachegrind/

As well as (if the profile file is small) webgrind http://code.google.com/p/webgrind/

SeanJA
+1  A: 

In addition to the excellent xdebug (as mentioned by others), you can also look at xhprof.

Charles
is one faster than the other? I find xdebug changes things from: they are slow I wonder why, to: I will go make lunch and come back to it when it is done.
SeanJA
I haven't had the chance to use xhprof yet, so I can't testify as to the speed.
Charles
+1  A: 

Yes, use XDebug, and once you're in it, use this technique, which works on any platform.

Don't think of it as measuring time.

Think of it as trying to ask, predominantly, What is it doing, and Why is it doing it?

Mike Dunlavey