{"id":648,"date":"2016-01-10T14:05:43","date_gmt":"2016-01-10T06:05:43","guid":{"rendered":"http:\/\/yangwang.hk\/?p=648"},"modified":"2016-01-10T14:05:43","modified_gmt":"2016-01-10T06:05:43","slug":"3-11%e3%80%81%e5%85%b3%e4%ba%8e%e5%be%aa%e7%8e%af%e7%9a%84%e9%82%a3%e4%ba%9b%e4%b8%8d%e5%be%97%e4%b8%8d%e7%9f%a5%e7%9a%84%e4%b8%9c%e8%a5%bf","status":"publish","type":"post","link":"https:\/\/yangwang.hk\/?p=648","title":{"rendered":"3.11\u3001\u5173\u4e8e\u5faa\u73af\u7684\u90a3\u4e9b\u4e0d\u5f97\u4e0d\u77e5\u7684\u4e1c\u897f"},"content":{"rendered":"<p>\u5728\u524d\u9762\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u7b80\u5355\u7684\u8c08\u5230\u4e86c\u8bed\u8a00\u4e2d\u7684\u4e09\u79cd\u5faa\u73af\u8bed\u53e5\uff0c\u8981\u60f3\u719f\u7ec3\u7684\u4f7f\u7528\u5b83\u4eec\uff0c\u4f60\u8fd8\u9700\u8981\u7ecf\u8fc7\u4e00\u4e9b\u7ec3\u4e60\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u5728\u5faa\u73af\u4e2d\u6216\u8bb8\u8fd8\u6709\u4e00\u4e9b\u5bb9\u6613\u88ab\u4f60\u5ffd\u89c6\u7684\u5c0f\u95ee\u9898\uff0c\u8fd9\u91cc\u6211\u4eec\u5c31\u5c06\u4ed6\u4eec\u5355\u72ec\u62ff\u51fa\u6765\u8fdb\u884c\u8ba8\u8bba<\/p>\n<h3>\u5faa\u73af\u5d4c\u5957<\/h3>\n<p>\u57283.7\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u5c1d\u8bd5\u8fc7\u5c06while\u5faa\u73af\u5d4c\u5957\u8d77\u6765\uff0c\u6765\u5b8c\u6210\u4e00\u4e9b\u590d\u6742\u7684\u4efb\u52a1<\/p>\n<p>\u5f53\u7136\uff0c\u4f60\u53ef\u4ee5\u5c06\u4e0d\u540c\u7684\u5faa\u73af\u7ed3\u6784\u5d4c\u5957\u8d77\u6765\uff0c\u5982\u5728while\u5faa\u73af\u4e2d\u4f7f\u7528for\u5faa\u73af<\/p>\n<p>\u5d4c\u5957\u7684\u65b9\u6cd5\u548c\u524d\u9762\u4e00\u6837\uff0c\u56e0\u6b64\u6211\u4eec\u5c31\u4e0d\u7ed9\u51fa\u4ee3\u7801\u4e86\uff08\u8bf7\u81ea\u884c\u5c1d\u8bd5\uff09<\/p>\n<p>\u4f46\u662f\u6211\u4eec\u5374\u6709\u4e00\u4e2a\u524d\u9762\u6ca1\u6709\u8c08\u5230\u7684\u95ee\u9898\uff0c\u90a3\u5c31\u662f\u6548\u7387<\/p>\n<p>\u6709\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u5199\u51fa\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u8fd9\u6837\u7684\u4ee3\u7801<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nfor(foo=0;foo=1000;foo++)\r\n   for(bar=0;bar&lt;5;bar++)\r\n{\r\n    \/\/do somethfoong\r\n}\r\n\r\n\r\nfor(bar=0;bar&lt;5;bar++)\r\n     for(foo=0;foo&lt;1000;foo++)\r\n{\r\n    \/\/do somethfoong\r\n}\r\n<\/pre>\n<p>\u521d\u770b\u8fd9\u4e24\u4e2a\u4ee3\u7801\u4f3c\u4e4e\u6ca1\u6709\u4ec0\u4e48\u533a\u522b\uff0c\u7136\u800c\u8bf7\u6ce8\u610f\uff0c\u8fd9\u4e24\u4e2a\u4ee3\u7801\u7684\u5185\u5c42\u5faa\u73af\u548c\u5916\u5c42\u5faa\u73af\u7684\u5faa\u73af\u6b21\u6570\u662f\u4e0d\u540c\u7684<\/p>\n<p>\u524d\u8005\u6267\u884c\u7684\u662f1000*5\u6b21\u5faa\u73af\uff0c\u540e\u8005\u6267\u884c\u7684\u662f5*1000\u6b21\u5faa\u73af<\/p>\n<p>\u56e0\u800c\u524d\u8005\u5728\u6267\u884c\u65f6\u4ece\u5185\u5c42\u5faa\u73af\u5207\u6362\u5230\u5916\u5c42\u5faa\u73af\u7684\u6b21\u6570\u8981\u591a\u4e00\u4e9b<\/p>\n<p>\u56e0\u6b64\u6709\u4e9b\u8d44\u6599\u4e0a\u8bf4\uff0c\u540e\u8005\uff08\u53735*1000\uff09\u901f\u5ea6\u66f4\u5feb\u4e00\u4e9b\uff0c\u7136\u800c\u662f\u8fd9\u6837\u5417\uff1f<\/p>\n<p>\u7ecf\u591a\u65b9\u67e5\u8bc1\uff0c\u8fd9\u4e2a\u8bf4\u6cd5\u662f\u4e0d\u4e00\u5b9a\u6b63\u786e\u7684\uff01<\/p>\n<p>\u56e0\u4e3a\u901a\u5e38\u6765\u8bf4\uff0cCPU\u6267\u884c\u5faa\u73af\u5207\u6362\u65f6\u53ea\u662f\u8fdb\u884c\u4e86\u4e00\u4e2a\u8df3\u8f6c\u6307\u4ee4<\/p>\n<p>\u800c\u73b0\u5728\u7684cpu\u5927\u591a\u62e5\u6709\u52a0\u901f\u7684cache\u6765\u5b58\u653e\u5c06\u8981\u6267\u884c\u7684\u6307\u4ee4\u548c\u6570\u636e<\/p>\n<p>\u5728\u5faa\u73af\u5207\u6362\u65f6\uff0c\u53ef\u80fd\u4f1a\u5207\u6362\u5230cache\u5916\u9762\uff08cache\u6bd4\u8f83\u5c0f\uff0c\u4e0d\u53ef\u80fd\u50a8\u5b58\u6240\u6709\u5185\u5bb9\uff09\uff0ccpu\u4fbf\u53ea\u80fd\u4ece\u4f4e\u901f\u7684RAM\u4e0a\u8bfb\u53d6\u6570\u636e\u4e86<\/p>\n<p>\u8fd9\u6837cache\u7684\u4f18\u52bf\u4fbf\u65e0\u6cd5\u53d1\u6325\u51fa\u6765\uff0c\u56e0\u6b64\u6548\u7387\u6bd4\u8f83\u4f4e<\/p>\n<p>\u7136\u800c\u8fd9\u79cd\u4e1c\u897f\u5728\u8ba1\u7b97\u673a\u4e0a\u4f3c\u4e4e\u90fd\u80fd\u627e\u5230\u53cd\u4f8b\u3002\u7f16\u8bd1\u6211\u4eec\u5199\u7684\u4ee3\u7801\u7684\u7f16\u8bd1\u5668\u4e5f\u4e0d\u662f\u50bb\u5b50\uff08\u6bd5\u7adf\u4eba\u4eec\u82b1\u8d39\u4e86\u5927\u91cf\u65f6\u95f4\u7814\u7a76\u4f18\u5316\uff09\uff0c\u5b83\u4f1a\u4f18\u5316\u6211\u4eec\u6240\u7f16\u5199\u7684\u4ee3\u7801<\/p>\n<p>\u5176\u4e2d\u5f88\u5e38\u7528\u7684\u4e00\u4e2a\u201c\u9ed1\u79d1\u6280\u201d\u4fbf\u662f<strong>\u201c\u5faa\u73af\u5c55\u5f00\u201d<\/strong><\/p>\n<p>\u5faa\u73af\u5c55\u5f00\u662f\u6307\uff0c\u5bf9\u4e8e\u4e00\u4e9b\u5faa\u73af\u6b21\u6570\u7f16\u8bd1\u65f6\u4fbf\u80fd\u786e\u5b9a\u7684\u5faa\u73af\uff08\u901a\u5e38\u662f\u6b21\u6570\u8f83\u5c11\u7684\u5faa\u73af\uff09\u5728\u751f\u6210\u4ee3\u7801\u65f6\u7f16\u8bd1\u5668\u4f1a\u5c06\u5faa\u73af\u5c55\u5f00<\/p>\n<p>\u6bd4\u5982\u7c7b\u4f3c\u4e8e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nfor(int foo = 5; foo &amp;gt; 0; foo--)\r\nprintf(&quot;hi\\n&quot;);\r\n<\/pre>\n<p>\u8fd9\u6837\u7684\u5faa\u73af\uff0c\u7f16\u8bd1\u540e\u4f1a\u53d8\u4e3a<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nprintf(&quot;hi\\n&quot;);\r\nprintf(&quot;hi\\n&quot;);\r\nprintf(&quot;hi\\n&quot;);\r\nprintf(&quot;hi\\n&quot;);\r\nprintf(&quot;hi\\n&quot;);\r\n<\/pre>\n<p>\u4e8e\u662f\u5faa\u73af\u4fbf\u6210\u4e3a\u4e86\u7b80\u5355\u7684\u91cd\u590d\uff0c\u6ca1\u6709\u4e86\u5faa\u73af\uff0c\u6267\u884c\u6548\u7387\u66f4\u9ad8\uff08\u663e\u7136\u7684\u3002\u8fd9\u6837\u4ea7\u751f\u7684\u76ee\u6807\u6587\u4ef6\u4f1a\u7a0d\u5927\uff0c\u662f\u5178\u578b\u7684\u201c\u4ee5\u7a7a\u95f4\u6362\u65f6\u95f4\u201d\uff09<\/p>\n<p>\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e0a\u9762\u6240\u8bf4\u76841000*5\u5faa\u73af\u6216\u8bb8\u6bd45*1000\u66f4\u5feb<\/p>\n<p>\u6240\u4ee5\u7ea0\u7ed3\u79cd\u6548\u7387\u662f\u6ca1\u6709\u610f\u4e49\u7684\uff0c\u5927\u5bb6\u5728\u4e66\u5199\u5d4c\u5957\u5faa\u73af\u7684\u65f6\u5019\u8fd8\u662f\u600e\u4e48\u8212\u670d\uff0c\u600e\u4e48\u5199\u6e05\u6670\u5c31\u600e\u4e48\u5199\u5427<\/p>\n<h3>\u5faa\u73af\u5185\u7684\u53d8\u91cf\u58f0\u660e<\/h3>\n<p>\u5f88\u591a\u4eba\u559c\u6b22\u5728\u5faa\u73af\u5185\u58f0\u660e\u53d8\u91cf\uff0c\u800c\u4e14\u8fd9\u5728\u6709\u4e9b\u65f6\u5019\u5f88\u65b9\u4fbf<\/p>\n<p>\u4f46\u662f\u503c\u5f97\u6ce8\u610f\u7684\u662f\u53d8\u91cf\u7684\u201c\u6709\u6548\u8303\u56f4\u201d\uff0c\u5373\u4f5c\u7528\u57df\u3002<\/p>\n<p>\u4f8b\u5982\u5728c99\u6807\u51c6\u4e2d\u6dfb\u52a0\u4e86\u5728for\u7684\u7b2c\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e2d\u6dfb\u52a0\u53d8\u91cf\u5b9a\u4e49\u7684\u5199\u6cd5<\/p>\n<p>for(int foo=0;&#8230;)<\/p>\n<p>\u8fd9\u91cc\u5b9a\u4e49\u7684\u53d8\u91cffoo\u4ec5\u80fd\u5728\u6b64\u5faa\u73af\u5185\u4f7f\u7528\uff0c\u5728\u5faa\u73af\u5916\u9762\u662f\u65e0\u6cd5\u8bbf\u95ee\u8fd9\u4e2a\u53d8\u91cf\u7684<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u524d\u9762\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u7b80\u5355\u7684\u8c08\u5230\u4e86c\u8bed\u8a00\u4e2d\u7684\u4e09\u79cd\u5faa\u73af\u8bed\u53e5\uff0c\u8981\u60f3\u719f\u7ec3\u7684\u4f7f\u7528\u5b83\u4eec\uff0c\u4f60\u8fd8\u9700\u8981\u7ecf\u8fc7\u4e00\u4e9b\u7ec3\u4e60\u3002 \u5f53\u7136\uff0c\u2026 <span class=\"read-more\"><a href=\"https:\/\/yangwang.hk\/?p=648\">Read More: 3.11\u3001\u5173\u4e8e\u5faa\u73af\u7684\u2026 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-648","post","type-post","status-publish","format-standard","hentry","category-c"],"views":2094,"_links":{"self":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=648"}],"version-history":[{"count":2,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/648\/revisions"}],"predecessor-version":[{"id":653,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/648\/revisions\/653"}],"wp:attachment":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}