I want to use Xdebug to profile a single php file. From Xdebug documentation, it is said
Profiling is enabled by setting the xdebug.profiler_enable setting to 1 in php.ini. This instructs Xdebug to start writing profiling information into the dump directory configured with the xdebug.profiler_output_dir directive.
I tried but Xdebug will generate so many profile logs. I have no testing environment but only could use production server. I want to know is there any way to set just testing one page?
Any suggestions to do this?
---Update 02/11/2013---------------------------
Finally I choose facebook / xhprof as my production server profiler. I use xhprof_html everyday now. It save a lot of time and very easy to use, especially the Full Callgraph view.
-
So you have xdebug on production server. Nice, I always wanted one.dev-null-dweller– dev-null-dweller12/31/2012 22:55:50Commented Dec 31, 2012 at 22:55
-
What's the problem of Xdebug on production server? I could disable it when I don't need it.user503853– user50385312/31/2012 23:00:37Commented Dec 31, 2012 at 23:00
2 Answers 2
Use the trigger http://xdebug.org/docs/all_settings#profiler_enable_trigger and add it to your url. i.e. http://example.com/mypage.php?XDEBUG_PROFILE=1
Also, XHProf is preferred over XDebug when profiling on production: https://github.com/facebook/xhprof
-
1Thanks for XHProf on productionuser503853– user50385312/31/2012 23:09:19Commented Dec 31, 2012 at 23:09
There is another option in the xdebug configuration that will do this: xdebug.profiler_enable_trigger
. Set it to 1 and then open the URL you want to profile with a querystring suffix of ?XDEBUG_PROFILE
. It will then write a log just for that script.
-
If you want to profile single session in CLI use environment variable
export XDEBUG_CONFIG="idekey=session_name profiler_enable=1
instead.cprn– cprn09/22/2016 14:05:39Commented Sep 22, 2016 at 14:05