johndodo
johndodo

Reputation: 18291

How to generate flame graphs with PHP?

I learned about flame graphs and find them fascinating - however, I could find no useful reference on how to generate them for my PHP script(s). How can I gather the data and generate the graphs using PHP?

Upvotes: 35

Views: 4376

Answers (2)

David J Eddy
David J Eddy

Reputation: 2037

I found this article from platform.sh where they use xhprof to output the data set from the execution calls, then a perl script called flamegraph.pl process the data set to be displayed as a SVG. A bit more digging and I was able to find the official flame graph repo on GitHub that contains the flamegraph.pl logic. The three resources combined I was able to generate a flame graph as desired though YMMV.

Upvotes: 1

n00dl3
n00dl3

Reputation: 21574

You can use Xdebug to create cachegrind profiles of your php code. You can take a look to this project that handles xdebug's cachegrind output using php.

Upvotes: 8

Related Questions