xhprof icon indicating copy to clipboard operation
xhprof copied to clipboard

Configurable sampling interval and call-stack tracing depth

Open janpapenbrock opened this issue 10 years ago • 0 comments

This is basically just a rebase of #34. All implementation credit goes to @turchanov.

Reason for this rebase: The original PR contained some additional, unrelated changes.

This PR adds two options to configure xhprof_sample_* functions behavior:

  1. xhprof.sampling_interval - Configure the sampling interval in microseconds, i.e. the time between two samples being taken. Defaults to the current hard-coded default of 100 miliseconds (=100,000 microseconds).
  2. xhprof.sampling_depth - Configure the call stack depth being sampled, i.e. when set to 10, only the 10 deepest method calls are recorded. Defaults to INT_MAX.

Both additions are great for in-depth performance analysis of requests with short response times, where the original sampling interval of 100 miliseconds is not useful at all.

Exemplary usage in the wild:

    ini_set('xhprof.sampling_interval', 50000); // sample twice as often
    ini_set('xhprof.sampling_depth', 50);
    xhprof_sample_enable();

janpapenbrock avatar Jan 07 '16 12:01 janpapenbrock