I have a PHP website on a Apache server, and I would like to know if there are tools and other ways I can profile this to find bottlenecks on the code. What I need to know is what functions are taking long to process, etc.
Something like gprof, except for PHP on live apache server.
What are other ways to find bottlenecks in a PHP system.
You can use xdebug - once installed you can trigger profiling of requests in a variety of ways, and you wind up with a valgrind format profile for each request. Load this in WinCacheGrind, KCacheGrind or similar and drill down to find where all the time is spent!
Try XDebug ( http://www.xdebug.org/ ) you can trigger it with a get-parameter during your debugging-session. This will create cachegrind-files which you can check within KCacheGrind or WinCacheGrind (this first is much better)...
XHProf was designed for this use case.
XHProf (open sourced by Facebook in 2009) powers Facebook's XHProfLive -- a real-time performance monitoring system that provides function level insights from production tiers.
A snippet from XHProf doc:
XHProf is a light-weight instrumentation based profiler. During the data collection phase, it keeps track of call counts and inclusive metrics for arcs in the dynamic callgraph of a program. It computes exclusive metrics in the reporting/post processing phase. XHProf handles recursive functions by detecting cycles in the callgraph at data collection time itself and avoiding the cycles by giving unique depth qualified names for the recursive invocations.
XHProf's light-weight nature and aggregation capabilities make it well suited for collecting "function-level" performance statistics from production environments.
regards, Kannan Muthukkaruppan
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With