{"id":1346,"date":"2018-01-19T19:22:44","date_gmt":"2018-01-19T19:22:44","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/profiling-php-code-with-xdebug-and-kcachegrind-page-2\/"},"modified":"2018-01-19T19:24:43","modified_gmt":"2018-01-19T19:24:43","slug":"profiling-php-code-with-xdebug-and-kcachegrind-page-2","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/profiling-php-code-with-xdebug-and-kcachegrind-page-2\/","title":{"rendered":"Profiling PHP Code with Xdebug and KCacheGrind Page 2"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By W. Jason Gilmore<\/div>\n<div class=\"\">on December 30, 2010<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\">\n<h2>Reviewing Performance Using the Source Code<\/h2>\n<div class=\"articlePara\">KCacheGrind offers numerous ways to peer into your application&#8217;s performance, among them the ability to tie execution times directly to the source code. Figure 3 presents KCacheGrind&#8217;s annotated view of the profiled source code, prepending the execution time to each respective line.<\/div>\n<div class=\"articlePara\"><a href=\"https:\/\/phpbuilder.com\/wp-content\/uploads\/2018\/01\/OptimizingPHP_figure3.png\" target=\"newFrame\"><br \/>\n<br \/><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/phpbuilder.com\/wp-content\/uploads\/2018\/01\/OptimizingPHP_figure3.png\" width=\"352\" height=\"156\"\/><br \/><font size=\"1\"><em>Click here for larger image<\/em><\/font><\/a><br \/>\n<br \/><font size=\"2\"><strong>Figure 3.<\/strong> Tying Execution Time to the Application Source Code<\/font><\/div>\n<h2>Reviewing Call Graphs<\/h2>\n<div class=\"articlePara\">Another interesting way to peer into your application&#8217;s execution cycle is via KCacheGrind&#8217;s Call Graph feature, an example of which is found in Figure 4. This graph not only traces the execution flow, but also associates call frequencies and the amount of total execution time required by each step in the cycle.<\/div>\n<div class=\"articlePara\"><a href=\"https:\/\/phpbuilder.com\/wp-content\/uploads\/2018\/01\/OptimizingPHP_figure4.png\" target=\"newFrame\"><br \/>\n<br \/><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/phpbuilder.com\/wp-content\/uploads\/2018\/01\/OptimizingPHP_figure4.png\" width=\"352\" height=\"182\"\/><br \/><font size=\"1\"><em>Click here for larger image<\/em><\/font><\/a><br \/>\n<br \/><font size=\"2\"><strong>Figure 4.<\/strong> Reviewing a Zend Framework Action Call Graph<\/font><\/div>\n<h2>Further Reading<\/h2>\n<div class=\"articlePara\">Xdebug and KCacheGrind offer invaluable insight into application performance, not only presenting a comprehensive breakdown of the entire cycle&#8217;s execution time but also providing the ability to visually trace the execution path using a variety of tabular and flowchart-based views. Be sure to check out the following resources for more information about optimizing your PHP applications:<\/div>\n<ul>\n<li><a href=\"http:\/\/code.google.com\/speed\/articles\/optimizing-php.html\" target=\"newFrame\">PHP performance tips<\/a>: A short but insightful series of PHP optimization tips<\/li>\n<li><a href=\"http:\/\/www.developer.com\/open\/article.php\/3901666\/Getting-Started-with-Memcached-Distributed-Memory-Caching.htm\">Memcached<\/a>: A popular caching solution used by high-traffic sites including Digg, Craigslist, and Twitter, among others<\/li>\n<li><a href=\"http:\/\/php.net\/manual\/en\/book.apc.php\" target=\"newFrame\">The Alternative PHP Cache<\/a>: A popular PHP code caching and optimization solution<\/li>\n<\/ul>\n<h2>About the Author<\/h2>\n<div class=\"articlePara\"><em><strong>Jason Gilmore<\/strong> is founder of the publishing, training, and consulting firm <a href=\"http:\/\/www.wjgilmore.com\/\" target=\"newFrame\">WJGilmore.com<\/a>. He is the author of several popular books, including <a href=\"http:\/\/www.wjgilmore.com\/\" target=\"newFrame\">&#8220;Easy PHP Websites with the Zend Framework&#8221;<\/a>, <a href=\"http:\/\/www.wjgilmore.com\/\" target=\"newFrame\">&#8220;Easy PayPal with PHP&#8221;<\/a>, and <a href=\"http:\/\/www.amazon.com\/dp\/1430231149\/\" target=\"newFrame\">&#8220;Beginning PHP and MySQL, Fourth Edition&#8221;<\/a>. Follow him on Twitter at <a href=\"http:\/\/www.twitter.com\/wjgilmore\" target=\"newFrame\">@wjgilmore<\/a>.<\/em><\/div>\n<\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"Jason_Gilmore12302010.html\">\u00ab Previous Page<\/a><\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"Jason_Gilmore12302010.html\">1<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">2<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use Xdebug and KCacheGrind to begin profiling and analyzing your PHP-driven Web<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1346","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=1346"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1346\/revisions"}],"predecessor-version":[{"id":2171,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1346\/revisions\/2171"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}