Hacker News new | ask | show | jobs
by morganpyne 5275 days ago
I have found Facebook's xhprof extension to be a a very useful extension for profiling also https://github.com/facebook/xhprof.

Unlike the one above, it doesn't require any code changes (it's a C-based PECL extension), and can easily be set up to be triggered via a parameter on the URL or to profile every nth page load (via a simple auto-prepend) for usage in production environments. It produces a full callgraph (using graphviz), you can drill down into the profile interactively, and you can record and compare profiles over time of the same page. It's also really quick and easy to setup and use.

There are of course other extensions that can do some profiling such as APD and XDebug, but xhprof is my personal favourite. I'm not sure I would ever be keen on confining my profiling to a PHP profiler written in PHP, although you do get some similar functionality from some frameworks such as debug mode in the Symfony framework.

2 comments

There's also a GUI tool to go along with the backend work: http://phpadvent.org/2010/profiling-with-xhgui-by-paul-reinh...
Thank you, I had not seen your fork and modifications before. Will check them out!
Profiling PHP with PHP is kind of humorous, I'll concede. But it can certainly help alert you to slow-running pages, queries, and steps. Which should at least give you a starting point or prompt you to dive deeper with a stronger/more robust tool like xdebug+kcachegrind.

Thanks for checking out the library and providing feedback though, I appreciate it!