Pantheon Community

What do you use for iterative PHP performance debugging?

I was recently reviewing an old blog post draft with @dgorton about performance tuning and I started questioning if my own knowledge is out of date.

Pantheon’s integration with New Relic is great for telling you if you have a performance problem and where it is. But I wouldn’t want to use it as my only tool for then correcting a certain type of problem.

What do you personally do when you hit a situation like this:

  • You think a section of code is taking too long to execute.
  • You want to measure the execution time of that section.
  • You want to make tweaks, run the code, see if it got better or worse.

The tool I used most successfully for that style of development was XHProf, which seems to be unmaintained now. I used Blackfire somewhat successfully a few years ago. And XDebug has a profiler, but I haven’t tried it in a long time.

1 Like

I generally use XDebug as a debugger and profiler when trying to pin down which code and why. I use PHPStorm connected to the debugger for breakpoints and step throughs.

However for your exact question about performance tuning a specific function, I would generally write or use an existing unit test that hits the code you’re after, put some timings in there and execute the unit test repeatedly (say average time over 5 executions) while making changes. This allows me to quickly turn around the code in comparison to testing through the UI and ensures I don’t break anything (if my unit test passes!).

Agreed to all the above. Generally my process has always been to start with XHProf or Blackfire (if I don’t have a New Relic report available), and then follow up with Xdebug to at least start stepping through the problem and performance issue.

I’ve seen Tideways as an option, but have never personally used it since it always seemed like I needed a paid account. At least with Blackfire, you can almost always run a single performance test on a free account, you just don’t get to keep them forever, or get the advanced insights without a paid account.

Similar to above answers, I use xdebug with PHPstorm to step through code.

I use New Relic to pinpoint areas on concern on the production site.

I have tried webprofiler with Devil module, but have not gotten it to play nice on my local docker. I could not give it enough php memory.