Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
January 19, 2010, 9:30 am
rate this thread
Just a quickie.
Is there a way of getting a detailed breakdown of just what functions/
methods are getting called on a given invocation of a script, how
often they're called and the time used, in other words a comprehensive
profile? I ask because I made what I thought was a minor change on a
project and now suddenly the SQL querying phase of the script takes a
10th of a second longer than before. Microtime just isn't cutting it
as a tool to figure out why.
Ideally I'd like something that generates a report similar to the
If the sql query is taking longer, and that is what you have changed, then
it's probably the sql query that is taking longer. Why the need to profile
the rest of the script?
The sort of answer you might get in a more relevant newsgroup (that is, a
database one) might be that you may need to add another index to whatever
table you are querying. But that's purely guesswork as you have supplied no
code to look at.
I've not made any changes to either the queries or the database
they're querying. Therefore I must have inadvertently put an unneeded
method call in somewhere that I need to get rid of but can't track
down. Therefore it's a PHP profiler I need. Not really been able to
find one that really produces what I need (method names, callers,
runtimes, run counts, etc, like what firebug generates for a
Chances are that the SQL query itself needs more time.
You CAN use microsecondes to test that (as a rough estimate).
I have done so many times before: no need for a profiler. Just make sure
you do a few test to get a reasonable average.
If it turns out that the SQL query itself is consuming the extra time,
AND you do care about the 1/10 sec, you can try to optimize the query or
maybe change the database (indexing).
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
- Captain Paralytic
January 19, 2010, 10:19 am
- Captain Paralytic
January 20, 2010, 10:58 am
January 19, 2010, 11:58 am
El 19/01/2010 10:30, Gordon escribió:
Good old Xdebug can generate profile information in a file format that
can be analized with WinCacheGrind:
It's not very fancy but kind of works.
I also have in my bookmarks a tool called "PHP Quick Profiler" I haven't
had time to explore:
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
- Thomas Mlynarczyk
January 19, 2010, 5:24 pm
I would certainly advice using cachegrind in linux enviroiment - it's by far
superior to wincachegrind. I develop on windows box but when I need
profiling on the level that my framework cannot produce I use VMvare virtual
machine with ubuntu installed and run full cachegrind of files generated on
my windows box running php/xdebug. It's maybe a little roundabout way but
when you get it working it works just fine - and results are order of
magnitude better than anything else I've tried (wincachegrind and also zend
profiler). I'm not aware of any better method :)
- » Memcached - memory usage efficiency / data compression
- — Next thread in » PHP Scripting Forum