4

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.

asked Dec 31, 2012 at 22:49
2
  • So you have xdebug on production server. Nice, I always wanted one. Commented 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. Commented Dec 31, 2012 at 23:00

2 Answers 2

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

answered Dec 31, 2012 at 22:53
1
  • 1
    Thanks for XHProf on production Commented Dec 31, 2012 at 23:09
2

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.

answered Dec 31, 2012 at 22:53
1
  • If you want to profile single session in CLI use environment variable export XDEBUG_CONFIG="idekey=session_name profiler_enable=1 instead. Commented Sep 22, 2016 at 14:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.