Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Turn On/Off Xdebug Profiling at Runtime?

I am currently using xdebug and experimenting with profiling and viewing w/ KCacheGrind. I have it set to only operate on trigger, i.e. passing XDEBUG_PROFILE=1 via GET.

There is a lot of noise in the output concerning the framework I am using and would like to be able to specifically profile a chunk of my code, like a controller, rather than the entire request.

Am I able to have xdebug profiling turned off until I choose to turn it on, like in a controller, and then turn it back off when I want?

like image 640
Jeremy Harris Avatar asked Nov 14 '22 09:11

Jeremy Harris


1 Answers

Am I able to have xdebug profiling turned off until I choose to turn it on, like in a controller, and then turn it back off when I want?

No, you either profile the request or you won't. You can not switch it on in one function and switch it of in another within the same request.

It wouldn't make much sense for a single request somehow, because you need to metric each part of the application in relevance to the other parts.

Alternatively there is the xhprof extension.

If you need to profile data over time from within specific areas, take a look at the Pinba PHP Extension.

like image 170
hakre Avatar answered Nov 16 '22 04:11

hakre