{"id":167837,"date":"2013-02-04T12:40:03","date_gmt":"2013-02-04T08:40:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=167837"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=167837","title":{"rendered":"<span class=\"post_title\">\u041f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412\u0441\u0435 \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u0430\u043c\u0438. \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438 \u0442\u0430\u043a\u043e\u0432\u0430, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u00ab\u043f\u043e\u0434 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u043e\u043c\u00bb \u0430 \u0437\u0430\u0442\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u044b\u0440\u043e\u0439 \u0434\u0430\u043c\u043f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442.<br \/>  \u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0438\u043c\u0435\u044f root&#8217;\u0430 \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u00ab\u043a\u0430\u043a \u043d\u0430\u0434\u043e\u00bb, \u0430 \u0441\u0435\u0439\u0447\u0430\u0441 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a. \u0418 \u0445\u043e\u0442\u0438\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e. \u0417\u043d\u0430\u043a\u043e\u043c\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f?<br \/>  \u0422\u043e\u0433\u0434\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u044b \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u044b. \u0410 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0448\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h1>\u041f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u044b<\/h1>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u2014 \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043e \u043d\u0435\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445. \u0410 \u043f\u043e\u043a\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u0438 4:<\/p>\n<h3>I. gprof<\/h3>\n<p>\u0421\u0442\u0430\u0440\u044b\u0439-\u0434\u043e\u0431\u0440\u044b\u0439 UNIX \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u0441\u043b\u043e\u0432\u0430\u043c \u041a\u0438\u0440\u043a\u0430 \u041c\u0430\u043a\u041a\u0443\u0437\u0438\u043a\u0430, \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0411\u0438\u043b\u043b\u043e\u043c \u0414\u0436\u043e\u0435\u043c \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c BSD. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440 \u00ab\u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f\u00bb \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c \u2014 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0441\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u044d\u0442\u0438\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<br \/>  \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e gprof \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0435 \u0442\u043e\u0447\u043d\u043e \u00ab\u0437\u043d\u0430\u0435\u0442\u00bb \u0438 \u0442\u043e, <i>\u0441\u043a\u043e\u043b\u044c\u043a\u043e<\/i> \u0440\u0430\u0437 \u0431\u044b\u043b\u0430 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0418 \u0445\u043e\u0442\u044f \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445, \u044d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u2014 overhead \u043e\u0442 \u0437\u0430\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u0441\u0430\u043c\u043e \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 C++-\u043a\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0449\u0438\u0435 \u043a inline.<br \/>  \u0422\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, \u043d\u043e gprof \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438.<\/p>\n<h3>II. Callgrind<\/h3>\n<p>Callgrind \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e Valgrind&#8217;\u0430 \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u043e\u0434\u0430. Valgrind \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u00ab\u0432 \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0435\u00bb, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. Callgrind \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u0431\u0440\u0435\u0439\u043a\u043f\u043e\u0438\u043d\u0442\u0430\u0445 \u043d\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u0445 \u0442\u0438\u043f\u0430 <b>call<\/b> \u0438 <b>ret<\/b>. \u041e\u043d \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043a\u043e\u0434, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043e\u0442 5 \u0434\u043e 20 \u0440\u0430\u0437. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 runtime \u043e\u043d, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043d\u0435 \u0433\u043e\u0434\u0435\u043d.<br \/>  \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0435\u043d, \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 <a href=\"http:\/\/valgrind.org\/docs\/manual\/cl-format.html\">\u0444\u043e\u0440\u043c\u0430\u0442 \u0433\u0440\u0430\u0444\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <\/a> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, kcachegrind.<\/p>\n<h3>III. OProfile<\/h3>\n<blockquote><p>OProfile is a system-wide profiler for Linux systems, capable of profiling all running code at low overhead. <\/p><\/blockquote>\n<p> OProfile \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0435\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u043e\u043c. \u0422.\u0435. \u043e\u043d \u043d\u0435 \u043d\u0430\u0446\u0435\u043b\u0435\u043d \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438, \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u0443\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443. OProfile \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043d\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0442\u0430\u0439\u043c\u0435\u0440, \u043a\u0430\u043a gprof \u0438\u043b\u0438 callgrind, \u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0438 CPU. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u0435\u043c\u043e\u043d\u0430 \u043e\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u043b\u0435\u0433\u0438\u0439.<br \/>  \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u043e\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u043a\u043e\u0433\u0434\u0430 \u0412\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0432\u0441\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441\u0440\u0430\u0437\u0443. \u0418 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u043e\u0435 \u043f\u0440\u0438 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u044f\u0434\u0440\u0430.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f OProfile 0.9.8<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0439 0.9.7 \u0438 \u0432 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0438\u0445 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440 \u0441\u043e\u0441\u0442\u043e\u044f\u043b \u0438\u0437 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u044f\u0434\u0440\u0430 \u0438 \u0434\u0435\u043c\u043e\u043d\u0430 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421 \u0432\u0435\u0440\u0441\u0438\u0438 0.9.8 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Linux Kernel Performance Events (\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u044f\u0434\u0440\u043e 2.6.31 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0432\u0435\u0436\u0435\u0435). \u0420\u0435\u043b\u0438\u0437 0.9.8 \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 &#8216;operf&#8217;, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0443\u044e \u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b.  <\/div>\n<\/div>\n<h3>IV. Google perftools<\/h3>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043d\u0430\u0431\u043e\u0440\u0430 Google perftools. \u042f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0435\u0433\u043e \u043e\u0431\u0437\u043e\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0442\u043a\u043e \u043e\u043f\u0438\u0448\u0443.<br \/>  \u041d\u0430\u0431\u043e\u0440 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u0435\u0440\u0438\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0430\u0446\u0435\u043b\u0435\u043d\u044b\u0445 \u043d\u0430 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437 C\/C++ \u2014 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0426\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440 <a href=\"http:\/\/gperftools.googlecode.com\/svn\/trunk\/doc\/tcmalloc.html\">tcmalloc<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0438\u043c\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435\u0441\u0435\u0442 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u2014 memory leaks \u0438 heap profile.<\/p>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"http:\/\/gperftools.googlecode.com\/svn\/trunk\/doc\/cpuprofile.html\">libprofiler<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f CPU. \u0412\u0430\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u043e\u043c, \u043a\u0430\u043a \u043e\u043d \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442. \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 (\u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 100) \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0438\u0433\u043d\u0430\u043b \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u0412 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0440\u0430\u0441\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0435\u043a \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439. \u041f\u043e-\u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044e \u0441\u044b\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0438 \u0433\u0440\u0430\u0444 \u0432\u044b\u0437\u043e\u0432\u043e\u0432.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0434\u0435\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f<\/b><\/p>\n<div class=\"spoiler_text\">1. \u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u043c \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0439\u043c\u0435\u0440 ITIMER_PROF, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0438\u043a\u0430\u0435\u0442 \u043b\u0438\u0448\u044c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 CPU. \u0412\u0435\u0434\u044c, \u043a\u0430\u043a-\u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043d\u0430\u043c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0433\u0434\u0435 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 <i>\u043e\u0436\u0438\u0434\u0430\u044f<\/i> \u0432\u0432\u043e\u0434 \u0441 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b \u0438\u043b\u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0441\u043e\u043a\u0435\u0442\u0443. \u0410 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>env CPUPROFILE_REALTIME=1<\/code><\/p>\n<p>  2. \u0421\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u0440\u0430\u0441\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e libunwind, \u043b\u0438\u0431\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e (\u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 &#8212;fno-omit-framepointer, \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 x86).<br \/>  3. \u0418\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0443\u0437\u043d\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e addr2line(1)<br \/>  4. \u041a\u0430\u043a \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 Google perftools, \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u0438\u043d\u043a\u043e\u0432\u0430\u043d \u044f\u0432\u043d\u043e, \u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u043f\u0440\u0435\u0434\u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 <code>LD_PRELOAD<\/code>.  <\/div>\n<\/div>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u2014 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c N \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0433\u0434\u0435 N \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u043e. \u042d\u0442\u043e \u0442.\u043d. \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440. \u0415\u0433\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0442\u0430\u043c \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u043e\u0441\u044c. \u0412\u0432\u0438\u0434\u0443 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u043e\u043d, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00bb.<br \/>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 google profiler \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439: <\/p>\n<ul>\n<li>\u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438<\/li>\n<li>\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 fork(2), \u043f\u043e\u0440\u043e\u0439 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u044f \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0434\u0435\u043c\u043e\u043d\u0430\u0445<\/li>\n<\/ul>\n<hr\/>\n<h1>Crxprof<\/h1>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u2014 <i>\u043b\u0435\u0433\u043a\u043e\u0435<\/i> \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 <i> \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445<\/i> \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.<\/p>\n<p>  \u041e\u043d \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u00ab\u0433\u043e\u0440\u044f\u0447\u0438\u0435\u00bb \u0447\u0430\u0441\u0442\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e ^C. \u0422\u0430\u043a\u0436\u0435 \u043e\u043d \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0433\u0440\u0430\u0444 \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u043c \u0440\u0430\u043d\u0435\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 callgrind. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e, \u0438 \u043a\u0430\u043a \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, crxprof \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a perftools, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <a href=\"http:\/\/man7.org\/linux\/man-pages\/man2\/ptrace.2.html\">ptrace(2)<\/a>. \u041f\u043e\u0434\u043e\u0431\u043d\u043e perftools \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"http:\/\/www.nongnu.org\/libunwind\/\">libunwind<\/a> \u0434\u043b\u044f \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0438 \u0441\u0442\u0435\u043a\u0430, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u044f\u0436\u0435\u043b\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0432\u043c\u0435\u0441\u0442\u043e <a href=\"http:\/\/linux.die.net\/man\/1\/addr2line\">addr2line(1)<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"http:\/\/en.wikipedia.org\/wiki\/Binary_File_Descriptor_library\">libbfd<\/a>.<\/p>\n<p>  \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f (SIGSTOP) \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e libunwind \u00ab\u0441\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f\u00bb \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u0430. \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0432 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 crxprof \u043a\u0430\u0440\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0439\u0442\u0438 \u043a\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0435\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044b\u0439 IP (instruction pointer).<\/p>\n<p>  \u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0433\u0440\u0430\u0444 \u0432\u044b\u0437\u043e\u0432\u0430, \u043f\u043e\u043b\u0430\u0433\u0430\u044f \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u0430\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u2014 \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e __libc_start_main \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libc.  <\/div>\n<\/div>\n<p>  <a href=\"https:\/\/github.com\/dkrotx\/crxprof\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a> \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 github. \u0422.\u043a. \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0438 \u043c\u043e\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u0433, \u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e \u0447\u0442\u043e \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0412\u0430\u0448\u0435\u043c\u0443 use-case&#8217;\u0443. \u0422\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0439\u0442\u0435.<\/p>\n<p>  \u0421\u043e\u0431\u0435\u0440\u0435\u043c crxprof \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h3>\u0421\u0431\u043e\u0440\u043a\u0430<\/h3>\n<p>  \u0427\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e: Linux (2.6+), autoconf+automake, binutils-dev (\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 libbfd), libunwind-dev (\u0443 \u043c\u0435\u043d\u044f \u043e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f libunwind8-dev).<br \/>  \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">autoreconf -fiv .\/configure make sudo make install <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 libunwind \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435:  <\/p>\n<pre><code class=\"bash\">.\/configure --with-libunwind=\/path\/to\/libunwind <\/code><\/pre>\n<h3>\u041f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435  <\/p>\n<pre><code class=\"bash\">crxprof pid <\/code><\/pre>\n<p>  \u0418 \u0432\u0441\u0435! \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 ^C \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c, \u0438 \u0434\u0432\u0430\u0436\u0434\u044b ^C^C \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f. Crxprof \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u043f\u0440\u043e\u0444\u0430\u0439\u043b \u0438 \u043f\u043e \u0432\u044b\u0445\u043e\u0434\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">crxprof: ptrace(PTRACE_ATTACH) failed: Operation not permitted<\/b><\/p>\n<div class=\"spoiler_text\">\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u044d\u0442\u0443 \u043e\u0448\u0438\u0431\u043a\u0443, \u0437\u043d\u0430\u0447\u0438\u0442 ptrace \u043d\u0430 \u0432\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u00ab\u0437\u0430\u043b\u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u00bb. (Ubuntu ?)<br \/>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/askubuntu.com\/questions\/41629\/after-upgrade-gdb-wont-attach-to-process\">\u0437\u0434\u0435\u0441\u044c<\/a><br \/>  \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u043b\u0438\u0431\u043e \u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435 \u0441 sudo, \u043b\u0438\u0431\u043e (\u043b\u0443\u0447\u0448\u0435) \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438:<\/p>\n<pre><code>$ echo 0 | sudo tee \/proc\/sys\/kernel\/yama\/ptrace_scope <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u0432\u0441\u0435 unix-\u0443\u0442\u0438\u043b\u0438\u0442\u044b, crxprof \u0432\u044b\u0432\u043e\u0434\u0438\u0442 usage \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0441 \u043a\u043b\u044e\u0447\u043e\u043c &#8212;help. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441\u043c. \u0432 <code>man crxprof<\/code>.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">crxprof &#8212;help<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre> Usage: crxprof [options] pid Options are:  -t|--threshold N:  visualize nodes that takes at least N% of time (default: 5.0)  -d|--dump FILE:    save callgrind dump to given FILE  -f|--freq FREQ:    set profile frequency to FREQ Hz (default: 100)  -m|--max-depth N:  show at most N levels while visualizing (default: no limit)  -r|--realtime:     use realtime profile instead of CPU  -h|--help:         show this help    --full-stack:      print full stack while visualizing  --print-symbols:   just print funcs and addrs (and quit) <\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"https:\/\/github.com\/dkrotx\/crxprof\/blob\/master\/test\/example.c\">\u044d\u0442\u043e\u0442 \u043a\u043e\u0434<\/a> \u043d\u0430 C. \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043c crxprof \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0433\u0440\u0430\u0444 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (4054 \u2014 pid \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b):<\/p>\n<pre><code class=\"bash\">$ crxprof -d \/tmp\/test.calls 4054 Reading symbols (list of function) reading symbols from \/home\/dkrot\/work\/crxprof\/test\/a.out (exe) reading symbols from \/lib\/x86_64-linux-gnu\/libc-2.15.so (dynlib) reading symbols from \/lib\/x86_64-linux-gnu\/ld-2.15.so (dynlib) Attaching to process: 6704 Starting profile (interval 10ms) Press ^C once to show profile, twice to quit ^C1013 snapshot interrputs got (0 dropped) main (100% | 0% self)  \\_ heavy_fn (75% | 49% self)    \\_ fn (25% | 25% self)  \\_ fn (24% | 24% self) Profile saved to \/tmp\/test.calls (Callgrind format) <\/code><\/pre>\n<p>  \u041f\u043e \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u0432\u0438\u0434\u043d\u043e \u0447\u0442\u043e:  <\/p>\n<ul>\n<li><b>main()<\/b> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <b>heavy_fn()<\/b> (\u0438 \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u00ab\u0442\u044f\u0436\u0435\u043b\u044b\u0439\u00bb \u043f\u0443\u0442\u044c)<\/li>\n<li><b>heavy_fn()<\/b> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <b>fn()<\/b><\/li>\n<li><b>main()<\/b> \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <b>fn()<\/b> \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e<\/li>\n<li><b>heavy_fn()<\/b> \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 CPU<\/li>\n<li><b>fn()<\/b> \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u0432\u0440\u0435\u043c\u044f CPU<\/li>\n<li><b>main()<\/b> \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/9a8\/fa0\/0e5\/9a8fa00e51bbf6e48b08de17e24dad34.png\" align=\"right\"\/><br \/>  \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0445\u0435\u043c\u0435 \u00ab\u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u044f \u2014 \u043f\u0435\u0440\u0432\u044b\u043c\u0438\u00bb. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445.<\/p>\n<p>  \u0414\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0433\u0440\u0430\u0444\u043e\u0432 \u0432\u044b\u0437\u043e\u0432\u0430 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c KCachegrind:<\/p>\n<pre><code class=\"bash\">$ kcachegrind \/tmp\/test.calls <\/code><\/pre>\n<p>  \u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0443 \u043c\u0435\u043d\u044f, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u043f\u0440\u0430\u0432\u0430.<br \/>  \u0412\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u043e\u043c\u043d\u044e \u0447\u0442\u043e \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u043e\u043c \u043f\u043e\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u0433 \u0438 \u044f \u0441\u0430\u043c. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438 \u0412\u0430\u043c.    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/167837\/\"> http:\/\/habrahabr.ru\/post\/167837\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412\u0441\u0435 \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u0430\u043c\u0438. \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438 \u0442\u0430\u043a\u043e\u0432\u0430, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u00ab\u043f\u043e\u0434 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u043e\u043c\u00bb \u0430 \u0437\u0430\u0442\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u044b\u0440\u043e\u0439 \u0434\u0430\u043c\u043f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442.<br \/>  \u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0438\u043c\u0435\u044f root&#8217;\u0430 \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u00ab\u043a\u0430\u043a \u043d\u0430\u0434\u043e\u00bb, \u0430 \u0441\u0435\u0439\u0447\u0430\u0441 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a. \u0418 \u0445\u043e\u0442\u0438\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e. \u0417\u043d\u0430\u043a\u043e\u043c\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f?<br \/>  \u0422\u043e\u0433\u0434\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u044b \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u044b. \u0410 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0448\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-167837","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/167837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=167837"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/167837\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=167837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=167837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=167837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}