preinheimer / xhprof

XHGUI is a GUI for the XHProf PHP extension, using a database backend, and pretty graphs to make it easy to use and interpret.
Other
833 stars 185 forks source link

Allow setting $weight to 0 to disable random profiling. #116

Closed MarkRose closed 5 years ago

aik099 commented 5 years ago
  1. How does random profiling work?
  2. Is the random profiling the default way to profile?

I've usually add ?_profile=1 to the URL and after redirect all pages on website are profile. Maybe that is an indication that random profiling is disabled by default?

MarkRose commented 5 years ago

If you add ?_profile=1, it will set a cookie that triggers profiling. When the cookie is present $_xhprof['doprofile'] is set to true.

If $_xhprof['doprofile'] is false, then lines 108 through 117 will randomly trigger profiling, with a 1 in $weight chance. $weight is set in config.php. Without this patch, there is no way to disable the random profiling from occurring. With this patch, setting $weight to 0 (or any falsy value) will disable the random profiling.

aik099 commented 5 years ago

I see. Then I like this change.

aik099 commented 5 years ago

Merging, thanks @MarkRose .