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...
Asked
Active
Viewed 1,605 times
4 Answers
6
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
- 92,731
- 24
- 156
- 164
-
You beat me twice!?!? curses! – SeanJA Apr 22 '10 at 04:36
-
Haha... it's like the Wild West of programming around here ;) – zombat Apr 22 '10 at 04:41
-
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... – Pablo Apr 22 '10 at 06:56
-
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 Apr 22 '10 at 17:42
-
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 Apr 23 '10 at 03:55
-
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 Apr 23 '10 at 04:16
2
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
- 10,234
- 5
- 32
- 42
1

Charles
- 50,943
- 13
- 104
- 142
-
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 Apr 22 '10 at 04:39
-
I haven't had the chance to use xhprof yet, so I can't testify as to the speed. – Charles Apr 22 '10 at 15:02
1
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?

Community
- 1
- 1

Mike Dunlavey
- 40,059
- 14
- 91
- 135