{"id":5368,"date":"2015-02-25T20:43:43","date_gmt":"2015-02-25T11:43:43","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=5368"},"modified":"2015-02-25T21:51:38","modified_gmt":"2015-02-25T12:51:38","slug":"cpu-%e6%99%82%e9%96%93%e3%82%92%e6%ad%a3%e7%a2%ba%e3%81%ab%e8%a8%88%e6%b8%ac%e3%81%99%e3%82%8b%ef%bc%88%e3%81%9d%e3%81%ae%ef%bc%91%ef%bc%89","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=5368","title":{"rendered":"CPU \u6642\u9593\u3092\u6b63\u78ba\u306b\u8a08\u6e2c\u3059\u308b\uff08\u305d\u306e\uff11\uff09"},"content":{"rendered":"<p>\u307e\u305a\u306f\u4e00\u822c\u8ad6\u304b\u3089\u3002<\/p>\n<p><a href=\"http:\/\/umezawa.dyndns.info\/wordpress\/?p=4560#comment-65746\">\u3053\u306e\u30b3\u30e1\u30f3\u30c8<\/a>\u3067 vctest \u306b CPU \u4f7f\u7528\u7387\u3092\u8a08\u6e2c\u3059\u308b\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u3066\u307b\u3057\u3044\u3068\u8a00\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u51e6\u7406\u306e\u7d4c\u904e\u6642\u9593\u306f\u65e2\u306b\u8a08\u6e2c\u3067\u304d\u3066\u3044\u308b\u306e\u3067 CPU \u6642\u9593\uff08\u4f7f\u7528\u91cf\uff09\u3092\u8a08\u6e2c\u3067\u304d\u308c\u3070\u5272\u308a\u7b97\u3059\u308b\u3060\u3051\u3067\u3059\u304c\u3001\u4e16\u306e\u4e2d\u305d\u3093\u306a\u306b\u7c21\u5358\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p><!--more--><\/p>\n<p>Windows \u306b\u304a\u3044\u3066 CPU \u6642\u9593\u3092\u8a08\u6e2c\u3059\u308b\u306b\u306f GetProcessTimes()\/GetThreadTimes() Win32 API \u3092\u4f7f\u3044\u307e\u3059\u3002\u3053\u308c\u3092\u4f7f\u3046\u3068\u3001\u6307\u5b9a\u3057\u305f\u30d7\u30ed\u30bb\u30b9\/\u30b9\u30ec\u30c3\u30c9\u306e\u751f\u6210\u6642\u523b\u3001\u7d42\u4e86\u6642\u523b\uff08\u3059\u3067\u306b\u7d42\u4e86\u3057\u305f\u30d7\u30ed\u30bb\u30b9\/\u30b9\u30ec\u30c3\u30c9\u306e\u307f\uff09\u3001\u30ab\u30fc\u30cd\u30eb\u6642\u9593\u3001\u30e6\u30fc\u30b6\u30fc\u6642\u9593\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u3092\u4f7f\u3048\u3070\u30b5\u30c3\u30af\u30ea\u7d42\u4e86\u2026\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3053\u306e API \u3067\u53d6\u308c\u308b\u6642\u9593\u306f\u7d04 1\/64 \u79d2\u306e\u7cbe\u5ea6\u3057\u304b\u306a\u3044\u306e\u3067\u3059\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u3001<\/p>\n<blockquote>\n<pre>int main(void)\r\n{\r\n    for (int i = 0; i &lt; 10; i ++)\r\n    {\r\n        FILETIME ftCreation, ftExit, ftKernel, ftUser;\r\n        ULARGE_INTEGER ulKernel, ulUser;\r\n\r\n        GetProcessTimes(GetCurrentProcess(), &ftCreation, &ftExit, &ftKernel, &ftUser);\r\n        ulKernel.LowPart  = ftKernel.dwLowDateTime;\r\n        ulKernel.HighPart = ftKernel.dwHighDateTime;\r\n        ulUser.LowPart    = ftUser.dwLowDateTime;\r\n        ulUser.HighPart   = ftUser.dwHighDateTime;\r\n        printf(\"%f %f\\n\", (double)ulKernel.QuadPart, (double)ulUser.QuadPart);\r\n    }\r\n\t\r\n    return 0;\r\n}<\/pre>\n<\/blockquote>\n<p>\u3068\u3044\u3046\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001<\/p>\n<blockquote>\n<pre>\r\nE:\\>GetProcessTimes.exe\r\n0.000000 0.000000\r\n0.000000 0.000000\r\n0.000000 0.000000\r\n0.000000 0.000000\r\n0.000000 0.000000\r\n0.000000 0.000000\r\n0.000000 0.000000\r\n0.000000 0.000000\r\n0.000000 0.000000\r\n0.000000 0.000000\r\n\r\nE:\\><\/pre>\n<\/blockquote>\n<p>\u306a\u3069\u3068\u51fa\u529b\u3055\u308c\u307e\u3059\u3057\u3001\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u3055\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u8868\u793a\u3057\u3088\u3046\u3068\u3057\u3066<\/p>\n<blockquote>\n<pre>int main(void)\r\n{\r\n    int count = 0;\r\n    FILETIME ftPrev = {0, 0};\r\n\r\n    while (count &lt; 10)\r\n    {\r\n        FILETIME ftCreation, ftExit, ftKernel, ftUser;\r\n        ULARGE_INTEGER ulUser;\r\n\t\t\r\n        for (int j = 0; j &lt; 1000*1000; j++)\r\n            ;\r\n\r\n        GetProcessTimes(GetCurrentProcess(), &ftCreation, &ftExit, &ftKernel, &ftUser);\r\n\t\t\r\n        if (memcmp(&ftPrev, &ftUser, sizeof(FILETIME)) != 0)\r\n        {\r\n            ulUser.LowPart    = ftUser.dwLowDateTime;\r\n            ulUser.HighPart   = ftUser.dwHighDateTime;\r\n            printf(\"%f\\n\", (double)ulUser.QuadPart);\r\n            ftPrev = ftUser;\r\n            count++;\r\n        }\r\n    }\r\n\t\r\n    return 0;\r\n}<\/pre>\n<\/blockquote>\n<p>\u3068\u3044\u3046\u30d7\u30ed\u30b0\u30e9\u30e0\uff08\u6700\u9069\u5316\u306f\u30aa\u30d5\u306b\u3059\u308b\u3053\u3068\uff09\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001<\/p>\n<blockquote>\n<pre>E:\\>GetProcessTimes.exe\r\n156001.000000\r\n312002.000000\r\n468003.000000\r\n624004.000000\r\n780005.000000\r\n936006.000000\r\n1092007.000000\r\n1248008.000000\r\n1404009.000000\r\n1560010.000000\r\n\r\nE:\\><\/pre>\n<\/blockquote>\n<p>\u306a\u3069\u3068\u8868\u793a\u3055\u308c\u307e\u3059\u3002FILETIME \u69cb\u9020\u4f53\u306f\u5024\u3092 100ns \u5358\u4f4d\u3067\u8fd4\u3059\u306e\u3067\u3001\u7cbe\u5ea6\u306f 156,001 \/ 10,000,000 = 1\/64.102&#8230; \u79d2\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u8a08\u6e2c\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u30b3\u30fc\u30c7\u30c3\u30af\u304c1\u30d5\u30ec\u30fc\u30e0\u51e6\u7406\u3059\u308b\u306e\u306b\u304b\u304b\u308b\u6642\u9593\u306f\u6570ms\u3067\u3042\u308a\u3001\u8a08\u6e2c\u306b\u306f\u30de\u30a4\u30af\u30ed\u79d2\u7cbe\u5ea6\u304c\u6c42\u3081\u3089\u308c\u308b\u305f\u3081\u3001\u3053\u308c\u3067\u306f\u4f7f\u3044\u7269\u306b\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u7d4c\u904e\u3057\u305f\u5b9f\u6642\u9593\u306f\u9ad8\u7cbe\u5ea6\u30a4\u30d9\u30f3\u30c8\u30bf\u30a4\u30de\u30fc (High Precision Event Timer; HPET) \u3068\u3044\u3063\u3066\u3001\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u304c\u6301\u3063\u3066\u3044\u308b\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3068\u306f\u7121\u95a2\u4fc2\u306b\u6b63\u78ba\u306b\u523b\u3080\u30bf\u30a4\u30de\u30fc\u3092\u4f7f\u3046\u3053\u3068\u3067\u30de\u30a4\u30af\u30ed\u79d2\u3088\u308a\u7d30\u304b\u3044\u7cbe\u5ea6\u3067\u8a08\u6e2c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff08Windows \u3060\u3068 QueryPerformanceCounter() Win32 API \u7d4c\u7531\u3067\u4f7f\u3048\u308b\uff09\u304c\u3001\u30d7\u30ed\u30bb\u30b9\u304c\u6d88\u8cbb\u3057\u305f\u6642\u9593\u306f OS \u306b\u3057\u304b\u5206\u304b\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u306a\u304a\u3001\u7cbe\u5ea6\u304c 1\/64 \u79d2\u3057\u304b\u306a\u3044\u306e\u306f\u5225\u306b Windows \u304c\u60aa\u3044\u308f\u3051\u3067\u306f\u306a\u304f\u3066\u3001\u4ed6\u306e OS \u3067\u3082\u4f3c\u305f\u3088\u3046\u306a\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\uff08<a href=\"http:\/\/umezawa.dyndns.info\/wordpress\/?p=5375\">\u305d\u306e\uff12<\/a>\u306b\u7d9a\u304f\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u307e\u305a\u306f\u4e00\u822c\u8ad6\u304b\u3089\u3002 \u3053\u306e\u30b3\u30e1\u30f3\u30c8\u3067 vctest \u306b CPU \u4f7f\u7528\u7387\u3092\u8a08\u6e2c\u3059\u308b\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u3066\u307b\u3057\u3044\u3068\u8a00\u308f\u308c\u3066\u3044\u307e\u3059\u3002 \u51e6\u7406\u306e\u7d4c\u904e\u6642\u9593\u306f\u65e2\u306b\u8a08\u6e2c\u3067\u304d\u3066\u3044\u308b\u306e\u3067 CPU \u6642\u9593\uff08\u4f7f\u7528\u91cf\uff09\u3092\u8a08\u6e2c\u3067\u304d\u308c\u3070\u5272\u308a\u7b97\u3059\u308b\u3060\u3051\u3067\u3059\u304c\u3001\u4e16\u306e [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40,27],"tags":[],"class_list":["post-5368","post","type-post","status-publish","format-standard","hentry","category-vctest","category-technology"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/5368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5368"}],"version-history":[{"count":9,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/5368\/revisions"}],"predecessor-version":[{"id":5381,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/5368\/revisions\/5381"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5368"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}