{"id":1197,"date":"2014-11-11T01:07:27","date_gmt":"2014-11-10T16:07:27","guid":{"rendered":"http:\/\/tech.akat.info\/?p=1197"},"modified":"2014-11-11T02:22:42","modified_gmt":"2014-11-10T17:22:42","slug":"xhprof%e3%81%a7php%e3%82%92%e8%a7%a3%e6%9e%90%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=1197","title":{"rendered":"XHProf\u3067PHP\u3092\u89e3\u6790\u3059\u308b"},"content":{"rendered":"<p>\u30d6\u30e9\u30a6\u30b6\u4e0a\u3067\u30d7\u30ed\u30d5\u30a1\u30a4\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3002xdebug\u3088\u308a\u3082\u624b\u8efd<\/p>\n<h1>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/usr\/local\/src# wget -d http:\/\/pecl.php.net\/get\/xhprof-0.9.4.tgz\r\nDEBUG output created by Wget 1.13.4 on linux-gnu.\r\n...\r\n\r\nroot@hostname:\/usr\/local\/src# tar xzvf xhprof-0.9.4.tgz \r\npackage.xml\r\nxhprof-0.9.4\/examples\/sample.php\r\nxhprof-0.9.4\/extension\/tests\/common.php\r\nxhprof-0.9.4\/extension\/tests\/xhprof_001.phpt\r\nxhprof-0.9.4\/extension\/tests\/xhprof_002.phpt\r\nxhprof-0.9.4\/extension\/tests\/xhprof_003.phpt\r\nxhprof-0.9.4\/extension\/tests\/xhprof_004_inc.php\r\nxhprof-0.9.4\/extension\/tests\/xhprof_004_require.php\r\nxhprof-0.9.4\/extension\/tests\/xhprof_004.phpt\r\nxhprof-0.9.4\/extension\/tests\/xhprof_005.phpt\r\nxhprof-0.9.4\/extension\/tests\/xhprof_006.phpt\r\nxhprof-0.9.4\/extension\/tests\/xhprof_007.phpt\r\nxhprof-0.9.4\/extension\/tests\/xhprof_008.phpt\r\nxhprof-0.9.4\/extension\/config.m4\r\nxhprof-0.9.4\/extension\/php_xhprof.h\r\nxhprof-0.9.4\/extension\/xhprof.c\r\nxhprof-0.9.4\/xhprof_html\/css\/xhprof.css\r\nxhprof-0.9.4\/xhprof_html\/docs\/index.html\r\nxhprof-0.9.4\/xhprof_html\/docs\/sample-callgraph-image.jpg\r\nxhprof-0.9.4\/xhprof_html\/docs\/sample-diff-report-flat-view.jpg\r\nxhprof-0.9.4\/xhprof_html\/docs\/sample-diff-report-parent-child-view.jpg\r\nxhprof-0.9.4\/xhprof_html\/docs\/sample-flat-view.jpg\r\nxhprof-0.9.4\/xhprof_html\/docs\/sample-parent-child-view.jpg\r\nxhprof-0.9.4\/xhprof_html\/jquery\/indicator.gif\r\nxhprof-0.9.4\/xhprof_html\/jquery\/jquery-1.2.6.js\r\nxhprof-0.9.4\/xhprof_html\/jquery\/jquery.autocomplete.css\r\nxhprof-0.9.4\/xhprof_html\/jquery\/jquery.autocomplete.js\r\nxhprof-0.9.4\/xhprof_html\/jquery\/jquery.tooltip.css\r\nxhprof-0.9.4\/xhprof_html\/jquery\/jquery.tooltip.js\r\nxhprof-0.9.4\/xhprof_html\/js\/xhprof_report.js\r\nxhprof-0.9.4\/xhprof_html\/callgraph.php\r\nxhprof-0.9.4\/xhprof_html\/index.php\r\nxhprof-0.9.4\/xhprof_html\/typeahead.php\r\nxhprof-0.9.4\/xhprof_lib\/display\/typeahead_common.php\r\nxhprof-0.9.4\/xhprof_lib\/display\/xhprof.php\r\nxhprof-0.9.4\/xhprof_lib\/utils\/callgraph_utils.php\r\nxhprof-0.9.4\/xhprof_lib\/utils\/xhprof_lib.php\r\nxhprof-0.9.4\/xhprof_lib\/utils\/xhprof_runs.php\r\nxhprof-0.9.4\/CHANGELOG\r\nxhprof-0.9.4\/CREDITS\r\nxhprof-0.9.4\/README\r\nxhprof-0.9.4\/LICENSE\r\nroot@hostname:\/usr\/local\/src# cd xhprof-0.9.4\/extension\/\r\nroot@hostname:\/usr\/local\/src\/xhprof-0.9.4\/extension# phpize\r\nConfiguring for:\r\nPHP Api Version:         20100412\r\nZend Module Api No:      20100525\r\nZend Extension Api No:   220100525\r\n\r\nroot@hostname:\/usr\/local\/src\/xhprof-0.9.4\/extension# .\/configure \r\nchecking for grep that handles long lines and -e... \/bin\/grep\r\nchecking for egrep... \/bin\/grep -E\r\n...\r\nroot@hostname:\/usr\/local\/src\/xhprof-0.9.4\/extension# make\r\n...\r\nroot@hostname:\/usr\/local\/src\/xhprof-0.9.4\/extension# make install\r\nInstalling shared extensions:     \/usr\/lib\/php5\/20100525\/\r\nroot@hostname:\/usr\/local\/src\/xhprof-0.9.4\/extension# vi \/etc\/php5\/conf.d\/30-xhprof.ini\r\n<\/pre>\n<p>phpinfo\u3067\u78ba\u8a8d\u3059\u308b<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-01.05.00.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-01.05.00.png\" alt=\"Screenshot 2014-11-11 at 01.05.00\" width=\"621\" height=\"184\" class=\"alignnone size-full wp-image-1198\" \/><\/a><\/p>\n<h1>\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3057\u3066\u307f\u308b<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/var\/www\/htdocs# cat index.php\r\n&lt;?php\r\n\/\/ \u30d7\u30ed\u30d5\u30a1\u30a4\u30ea\u30f3\u30b0\u306e\u958b\u59cb\r\nxhprof_enable();\r\n\r\nphpinfo();\r\n\r\n\/\/ \u30d7\u30ed\u30d5\u30a1\u30a4\u30ea\u30f3\u30b0\u306e\u7d42\u4e86\r\n$xhprof_data = xhprof_disable();\r\n\/\/ \u7d50\u679c\u306e\u8868\u793a\r\nvar_dump($xhprof_data);\r\n?&gt;\r\n<\/pre>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-01.19.48.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-01.19.48.png\" alt=\"Screenshot 2014-11-11 at 01.19.48\" width=\"897\" height=\"626\" class=\"alignnone size-full wp-image-1200\" \/><\/a><\/p>\n<h2>CodeIgniter\u3092\u8868\u793a\u30c4\u30fc\u30eb\u3092\u5229\u7528\u3057\u3066\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3059\u308b<\/h2>\n<p>\u8868\u793a\u30c4\u30fc\u30eb\u306f\u3001\u89e3\u51cd\u30d5\u30a1\u30a4\u30eb\u5185\u306e\u300cxhprof_html\u300d\u3068\u300cxhprof_lib\u300d\u304c\u5fc5\u8981\u3068\u306e\u3053\u3068<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/var\/www\/htdocs# cp -Rp \/usr\/local\/src\/xhprof-0.9.4 .\/\r\nroot@hostname:\/var\/www\/htdocs# mv xhprof-0.9.4 xhprof\r\nroot@hostname:\/var\/www\/htdocs# chown -R www-data:www-data xhprof\/\r\nroot@hostname:\/var\/www\/htdocs# aptitude install graphviz # \u30b0\u30e9\u30d5\u8868\u793a\u306e\u305f\u3081\u306b\u5fc5\u8981\r\n\u4ee5\u4e0b\u306e\u65b0\u898f\u30d1\u30c3\u30b1\u30fc\u30b8\r\n  fonts-liberation graphviz libcdt4{a} libcgraph5{a} libgraph4{a} libgvc5{a} libgvpr1{a} libpathplan4{a} libxdot4{a} ttf-liberation{a} \r\n...\r\nroot@hostname:\/var\/www\/htdocs# vi CI\/index.php # \u5148\u982d\u3068\u672b\u5c3e\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8ffd\u52a0\u3059\u308b\r\n&lt;?php\r\n\r\n\/\/----------------------------------------\r\n\/\/ XHProf\u3092\u4f7f\u3046\u304b\u3069\u3046\u304b\u306e\u8a2d\u5b9a TRUE \/ FALSE\r\n$xhprof_mode = TRUE;\r\n \r\n\/\/ start profiler\r\nif ($xhprof_mode) {\r\n    xhprof_enable();\r\n}\r\n\/\/----------------------------------------\r\n\r\n............(\u4e2d\u7565)\r\n\r\n\r\n\/\/----------------------------------------\r\n\/\/ stop profiler\r\nif ($xhprof_mode) {\r\n    $xhprof_data = xhprof_disable();\r\n \r\n    $XHPROF_ROOT = '\/var\/www\/htdocs\/xhprof';  \/\/xhprof\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\r\n    $XHPROF_SOURCE_NAME = 'CodeIgniter';\r\n    include_once $XHPROF_ROOT . '\/xhprof_lib\/utils\/xhprof_lib.php';\r\n    include_once $XHPROF_ROOT . '\/xhprof_lib\/utils\/xhprof_runs.php';\r\n    $xhprof_runs = new XHProfRuns_Default();\r\n    $run_id = $xhprof_runs-&gt;save_run($xhprof_data, $XHPROF_SOURCE_NAME);\r\n \r\n    echo &quot;&lt;a href='http:\/\/hostname\/xhprof\/xhprof_html\/index.php?run=$run_id&amp;source=$XHPROF_SOURCE_NAME' target='_blank'&gt;xhprof Result&lt;\/a&gt;&quot;;\r\n}\r\n\/\/----------------------------------------\r\n<\/pre>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-02.14.29.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-02.14.29.png\" alt=\"Screenshot 2014-11-11 at 02.14.29\" width=\"1308\" height=\"473\" class=\"alignnone size-full wp-image-1203\" \/><\/a><\/p>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-02.15.25.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-02.15.25.png\" alt=\"Screenshot 2014-11-11 at 02.15.25\" width=\"1352\" height=\"648\" class=\"alignnone size-full wp-image-1204\" \/><\/a><\/p>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-02.16.26.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/Screenshot-2014-11-11-at-02.16.26.png\" alt=\"Screenshot 2014-11-11 at 02.16.26\" width=\"1285\" height=\"618\" class=\"alignnone size-full wp-image-1205\" \/><\/a><\/p>\n<h1>\u53c2\u8003URL<\/h1>\n<p>PHP\u306e\u30d7\u30ed\u30d5\u30a1\u30a4\u30e9\u30fc\u300cXHProf\u300d\u306e\u4f7f\u3044\u65b9<br \/>\nhttp:\/\/hamamuratakuo.blog61.fc2.com\/blog-entry-466.html<\/p>\n<p>\u3010CakePHP\u3011xhprof\u3067CakePHP\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u4e38\u88f8\u306b\u3059\u308b<br \/>\nhttp:\/\/blog.ecworks.jp\/archives\/467<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30d6\u30e9\u30a6\u30b6\u4e0a\u3067\u30d7\u30ed\u30d5\u30a1\u30a4\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3002xdebug\u3088\u308a\u3082\u624b\u8efd \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5 root@hostname:\/usr\/local\/src# wget -d http:\/\/pecl.php.net\/get\/xhpro [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1197"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1197"}],"version-history":[{"count":6,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1197\/revisions"}],"predecessor-version":[{"id":1208,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1197\/revisions\/1208"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}