{"id":33,"date":"2018-01-28T17:04:57","date_gmt":"2018-01-28T09:04:57","guid":{"rendered":"https:\/\/blog.simbot.net\/?p=33"},"modified":"2018-01-28T17:04:57","modified_gmt":"2018-01-28T09:04:57","slug":"apitrace2","status":"publish","type":"post","link":"https:\/\/blog.simbot.net\/2018\/01\/28\/apitrace2\/","title":{"rendered":"apitrace\u539f\u7406\u5206\u6790\u53ca\u6539\u8fdb"},"content":{"rendered":"

apitrace\u539f\u7406\u5206\u6790\u53ca\u6539\u8fdb<\/h1>\n

\u4f5c\u8005\uff1ahws000\uff08hws.000#163.com\uff09
\n\u58f0\u660e\uff1a\u7248\u6743\u6240\u6709\uff0c\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u3002
\n\u51fa\u5904\uff1ahttps:\/\/blog.simbot.net\/index.php\/2018\/01\/28\/apitrace2\/<\/a><\/p>\n

\u524d\u6587<\/a>\u5bf9apitrace\u7684\u4f7f\u7528\u65b9\u6cd5\u505a\u4e86\u7b80\u5355\u4ecb\u7ecd\uff0c\u672c\u6587\u5c06\u4ecb\u7ecd\u5b83\u7684\u5b9e\u73b0\u539f\u7406\uff0c\u53ca\u5bf9\u65f6\u6233\u7cfb\u7edf\u7684\u6539\u8fdb\u3002<\/p>\n

1.\u539f\u7406<\/h2>\n

1.1\u91c7\u96c6\u5e76\u8bb0\u5f55\u6570\u636e<\/h3>\n

\u901a\u8fc7\u6e90\u7801\u4e2d\u7684specs\/glapi.py\u3001retrace\/glretrace.py\u7b49\u811a\u672c\uff0c\u5728\u7f16\u8bd1\u65f6\u751f\u6210build\/wrappers\/glxtrace.cpp\u6587\u4ef6\u3002\u6b64\u6587\u4ef6\u5305\u542b\u6240\u6709gl+glx\u7684\u51fd\u6570\u63a5\u53e3\uff08\u5185\u5bb9\u89c1\u4e0b\u56fe\uff09\uff0c\u8fd9\u4e9b\u51fd\u6570\u4f1a\u88ab\u7f16\u8bd1\u6210glxtrace.so\uff0capitrace trace\u8fd0\u884c\u65f6glxtrace.so\u6210\u4e3a\u5e94\u7528\u548cOpenGL\u9a71\u52a8\u4e4b\u95f4\u7684\u6865\u6881\uff0c\u540c\u65f6\u5c06\u6240\u6709gl\u51fd\u6570\u8c03\u7528\u8bb0\u5f55\u5230.trace\u6587\u4ef6\u4e2d\u3002.trace\u6587\u4ef6\u4e2d\u4f1a\u8bb0\u5f55\u5404\u4e2a\u53c2\u6570\u7684\u6570\u503c\uff0c\u5305\u62ec\u6307\u9488\u7c7b\u53c2\u6570\u7684\u5185\u5b58\u6570\u636e\u3002
\n\"\"<\/p>\n

1.2\u91cd\u73b0\u5e76\u8bb0\u5f55\u6267\u884c\u65f6\u95f4<\/h3>\n

\u6267\u884creplay\u6216qapitrace\u65f6\u4f1a\u76f4\u63a5\u4ece.trace\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u5e76\u4f9d\u6b21\u6267\u884c\u8bb0\u5f55\u7684\u51fd\u6570\uff0c\u4ece\u800c\u5c06\u8fd0\u884c\u60c5\u51b5\u91cd\u73b0\u3002\u5728\u91cd\u73b0\u7684\u8fc7\u7a0b\u4e2d\u901a\u8fc7glGetQueryObjecti64vEXT(query.ids[GPU_DURATION], GL_QUERY_RESULT, &gpuDuration)\u51fd\u6570\u83b7\u53d6gl\u51fd\u6570\u7684\u6267\u884c\u65f6\u95f4\u3002CPU\u65f6\u6233\u901a\u8fc7query.cpuStart = getCurrentTime()\uff0cquery.cpuEnd = getCurrentTime()\u83b7\u53d6\uff0c\u8fd9\u4e2a\u65f6\u6233\u662freplay\u7a0b\u5e8f\u8fd0\u884c\u7684\u5f53\u524d\u65f6\u95f4\u3002<\/p>\n

1.3\u95ee\u9898<\/h3>\n

\u7531\u4e8eCPU\u65f6\u6233\u662freplay\u65f6\u83b7\u53d6\u7684\uff0c\u5b9e\u9645\u4e0a\u662f\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u8bb0\u5f55\u6570\u636e\u5e76\u91cd\u653e\u7684\u65f6\u95f4\uff0c\u4e0d\u662f\u7a0b\u5e8f\u8fd0\u884c\u65f6\u771f\u6b63\u8c03\u7528gl\u51fd\u6570\u65f6\u7684\u65f6\u6233\uff0c\u4e0d\u80fd\u8868\u793aCPU\u903b\u8f91\u82b1\u8d39\u7684\u65f6\u95f4\u3002<\/p>\n

2.\u6539\u8fdb<\/h2>\n

2.1\u5bf9\u65f6\u6233\u7684\u6539\u8fdb<\/h3>\n

\u77e5\u9053\u4e86\u65f6\u6233\u4e0d\u51c6\u786e\u7684\u539f\u56e0\u6539\u8fdb\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u91c7\u96c6\u6570\u636e\u7684\u65f6\u95f4\u5c31\u662f\u6b63\u786e\u7684CPU\u65f6\u6233\uff0c\u5c06\u6b64\u65f6\u6233\u8bb0\u5f55\u5230.trace\u6587\u4ef6\u4e2d\uff0creplay\u65f6\u518d\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u5373\u53ef\u3002<\/p>\n

2.2\u5bf9qapitrace\u663e\u793a\u7ed3\u679c\u7684\u6539\u8fdb<\/h3>\n

\u5229\u7528CPU\u65f6\u6233\u7684\u6539\u8fdb\u7ed3\u679c\uff0c\u589e\u52a0\u663e\u793a\u51fd\u6570\u7684\u8017\u65f6\u548c\u6bcf\u5e27\u8017\u65f6\u3002<\/p>\n

2.3\u5176\u5b83\u7684\u6539\u8fdb<\/h3>\n

apitrace\u8bb0\u5f55\u548c\u91cd\u653e\u6570\u636e\u65f6\uff0c\u4f1a\u5bf9\u6bcf\u5e27\u7684\u7ed3\u675f\u505a\u6807\u8bc6\uff0c\u8ba4\u4e3aglFlush\u3001glFinish\u3001glXSwapBuffers\u7b49\u51fd\u6570\u662f\u4e00\u5e27\u7684\u7ed3\u675f\uff0c\u5728\u8fd9\u4e9b\u51fd\u6570\u6267\u884c\u65f6\u8c03\u7528frame_complete\u51fd\u6570\u3002\u5230firefox56\uff08\u8c8c\u4f3c\u662f\u3002\u3002\u3002\uff09\u65f6\uff0c\u4e0d\u4f1a\u8c03\u7528glXSwapBuffers\uff0c\u4e0d\u80fd\u6b63\u786e\u8bc6\u522b\u6bcf\u5e27\u7684\u7ed3\u675f\u4f4d\u7f6e\uff0c\u9700\u8981\u4fee\u6539retrace\/glretrace.py\u811a\u672c\u5e76\u91cd\u65b0\u7f16\u8bd1apitrace\u624d\u884c\u3002<\/p>\n

\u672c\u6587\u7684\u4fee\u6539\u53ef\u5728\u76ee\u524d\u6700\u65b0\u7684\u6e90\u7801\u4e0a\u7f16\u8bd1\u901a\u8fc7\uff0c\u6b64\u5904\u63d0\u4f9b\u4fee\u6539\u540e\u7684diff\u6587\u4ef6\uff0c\u4ecegithub\u4e0a\u540c\u6b65\u6e90\u7801\u540e\u6267\u884cgit apply\u547d\u4ee4\u5c31\u4f1a\u5c06\u4fee\u6539\u5408\u5e76\uff0c\u91cd\u65b0\u7f16\u8bd1\u5373\u53ef\u3002
\n
cputime-diff<\/a>
\n
gui-diff<\/a>
\n
other-diff<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

\u524d\u6587\u5bf9apitrace\u7684\u4f7f\u7528\u65b9\u6cd5\u505a\u4e86\u7b80\u5355\u4ecb\u7ecd\uff0c\u672c\u6587\u5c06\u4ecb\u7ecd\u5b83\u7684\u5b9e\u73b0\u539f\u7406\uff0c\u53ca\u5bf9\u65f6\u6233\u7cfb\u7edf\u7684\u6539\u8fdb\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[5,11,12],"_links":{"self":[{"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/posts\/33"}],"collection":[{"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":1,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":41,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/posts\/33\/revisions\/41"}],"wp:attachment":[{"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}