{"id":969,"date":"2019-10-19T16:50:44","date_gmt":"2019-10-19T08:50:44","guid":{"rendered":"http:\/\/iqotom.com\/?p=969"},"modified":"2023-04-04T17:52:12","modified_gmt":"2023-04-04T09:52:12","slug":"linux%e5%8e%8b%e5%8a%9b%e6%b5%8b%e8%af%95%e5%b7%a5%e5%85%b7stress%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"http:\/\/iqotom.com\/?p=969","title":{"rendered":"Linux\u538b\u529b\u6d4b\u8bd5\u5de5\u5177Stress\u5982\u4f55\u4f7f\u7528"},"content":{"rendered":"\n<p class=\"has-medium-font-size\">stress\u662f\u4e00\u4e2alinux\u4e0b\u7684\u538b\u529b\u6d4b\u8bd5\u5de5\u5177\uff0c \u4e3a\u5e0c\u671b\u5b8c\u5168\u5728\u9ad8\u8d1f\u8f7d\u4e0b\u6d4b\u8bd5\u5176\u7cfb\u7edf\u5e76\u76d1\u63a7\u8fd0\u884c\u72b6\u51b5\u7684\u7528\u6237\u800c\u8bbe\u8ba1 \u3002 <\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u7cfb\u7edf\u73af\u5883\uff1aUbuntu 18.04<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e0b\u8f7d\u5b89\u88c5 stress<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">apt install stress<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>stress \u5de5\u5177\u4f7f\u7528<\/strong><\/h2>\n\n\n\n<p><strong>stress \u7684\u547d\u4ee4\u53c2\u6570 <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">`stress' imposes certain types of compute stress on your system\n\nUsage: stress [OPTION [ARG]] ...\n -?, --help         show this help statement\n     --version      show version statement\n -v, --verbose      be verbose\n -q, --quiet        be quiet\n -n, --dry-run      show what would have been done\n -t, --timeout N    timeout after N seconds\n     --backoff N    wait factor of N microseconds before work starts\n -c, --cpu N        spawn N workers spinning on sqrt()\n -i, --io N         spawn N workers spinning on sync()\n -m, --vm N         spawn N workers spinning on malloc()\/free()\n     --vm-bytes B   malloc B bytes per vm worker (default is 256MB)\n     --vm-stride B  touch a byte every B bytes (default is 4096)\n     --vm-hang N    sleep N secs before free (default none, 0 is inf)\n     --vm-keep      redirty memory instead of freeing and reallocating\n -d, --hdd N        spawn N workers spinning on write()\/unlink()\n     --hdd-bytes B  write B bytes per hdd worker (default is 1GB)\n\nExample: stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s\n\nNote: Numbers may be suffixed with s,m,h,d,y (time) or B,K,M,G (size).<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">stress <strong>\u53c2\u6570\u8bf4\u660e\uff1a<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">-? \u663e\u793a\u5e2e\u52a9\u4fe1\u606f\n\n-v \u663e\u793a\u7248\u672c\u53f7\n\n-q \u4e0d\u663e\u793a\u8fd0\u884c\u4fe1\u606f\n\n-n \u663e\u793a\u5df2\u5b8c\u6210\u7684\u6307\u4ee4\u60c5\u51b5\n\n-t --timeout N \u6307\u5b9a\u8fd0\u884cN\u79d2\u540e\u505c\u6b62\n\n--backoff N \u7b49\u5f85N\u5fae\u5999\u540e\u5f00\u59cb\u8fd0\u884c\n\n-c \u4ea7\u751fn\u4e2a\u8fdb\u7a0b \u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u53cd\u590d\u4e0d\u505c\u7684\u8ba1\u7b97\u968f\u673a\u6570\u7684\u5e73\u65b9\u6839\n\n-i \u4ea7\u751fn\u4e2a\u8fdb\u7a0b \u6bcf\u4e2a\u8fdb\u7a0b\u53cd\u590d\u8c03\u7528sync()\uff0csync()\u7528\u4e8e\u5c06\u5185\u5b58\u4e0a\u7684\u5185\u5bb9\u5199\u5230\u786c\u76d8\u4e0a\n\n-m --vm n \u4ea7\u751fn\u4e2a\u8fdb\u7a0b,\u6bcf\u4e2a\u8fdb\u7a0b\u4e0d\u65ad\u8c03\u7528\u5185\u5b58\u5206\u914dmalloc\u548c\u5185\u5b58\u91ca\u653efree\u51fd\u6570\n\n--vm-bytes B \u6307\u5b9amalloc\u65f6\u5185\u5b58\u7684\u5b57\u8282\u6570 \uff08\u9ed8\u8ba4256MB\uff09\n\n--vm-hang N \u6307\u5b9a\u5728free\u94b1\u7684\u79d2\u6570\n\n-d --hadd n \u4ea7\u751fn\u4e2a\u6267\u884cwrite\u548cunlink\u51fd\u6570\u7684\u8fdb\u7a0b\n\n-hadd-bytes B \u6307\u5b9a\u5199\u7684\u5b57\u8282\u6570\n\n--hadd-noclean \u4e0dunlink\n\n\u65f6\u95f4\u5355\u4f4d\u53ef\u4ee5\u4e3a\u79d2s\uff0c\u5206m\uff0c\u5c0f\u65f6h\uff0c\u5929d\uff0c\u5e74y\uff0c\u6587\u4ef6\u5927\u5c0f\u5355\u4f4d\u53ef\u4ee5\u4e3aK\uff0cM\uff0cG<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">stress <strong>\u6d4b\u8bd5\u573a\u666f\u4e3e\u4f8b\uff1a<\/strong><\/h3>\n\n\n\n<p><strong> 1\u3001\u6d4b\u8bd5CPU\u8d1f\u8377 <\/strong><br> stress -c 4 -t 10 <br> \u589e\u52a04\u4e2acpu\u8fdb\u7a0b\uff0c\u5904\u7406sqrt()\u51fd\u6570\u51fd\u6570\uff0c\u4ee5\u63d0\u9ad8\u7cfb\u7edfCPU\u8d1f\u8377\uff0c\u6d4b\u8bd510s <\/p>\n\n\n\n<p><strong> 2\u3001\u5185\u5b58\u6d4b\u8bd5 <\/strong><br> stress -i 4 &#8211;vm 10 &#8211;vm-bytes 1G &#8211;vm-hang 100 &#8211;timeout 100s <br> \u65b0\u589e4\u4e2aio\u8fdb\u7a0b\uff0c10\u4e2a\u5185\u5b58\u5206\u914d\u8fdb\u7a0b\uff0c\u6bcf\u6b21\u5206\u914d\u5927\u5c0f1G\uff0c\u5206\u914d\u540e100s\u91ca\u653e<\/p>\n\n\n\n<p><strong> 3\u3001\u78c1\u76d8I\/O\u6d4b\u8bd5 <\/strong><br> stress \u2013d 1 &#8211;hdd-bytes 3G <br> \u65b0\u589e1\u4e2a\u5199\u8fdb\u7a0b\uff0c\u6bcf\u6b21\u51993G\u6587\u4ef6\u5757 <\/p>\n\n\n\n<p><strong> 4\u3001\u786c\u76d8\u6d4b\u8bd5 <\/strong><br> stress -i 1 -d 10 &#8211;hdd-bytes 3G &#8211;hdd-noclean <br> \u65b0\u589e1\u4e2aIO\u8fdb\u7a0b\uff0c10\u4e2a\u5199\u8fdb\u7a0b\uff0c\u6bcf\u6b21\u5199\u51653G\u6587\u4ef6\u5757\uff0c\u4e14\u4e0d\u6e05\u9664\uff0c\u4f1a\u9010\u6b65\u5c06\u786c\u76d8\u8017\u5c3d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5b89\u88c5htop\u76d1\u63a7\u8fdb\u7a0b<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">apt install htop\n#htop\u7684\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u8bf7\u81ea\u884c\u641c\u7d22<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5b89\u88c5sensors\u76d1\u63a7\u6e29\u5ea6<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">apt install lm-sensors\n#\u8f93\u5165sensors\u5373\u53ef\u68c0\u6d4b\u6e29\u5ea6\u548c\u98ce\u6247\u8f6c\u901f\nroot@ubuntu:~# sensors|grep -E 'Core|Package'\nPackage id 0:  +46.0\u00b0C  (high = +100.0\u00b0C, crit = +100.0\u00b0C)\nCore 0:        +42.0\u00b0C  (high = +100.0\u00b0C, crit = +100.0\u00b0C)\nCore 1:        +44.0\u00b0C  (high = +100.0\u00b0C, crit = +100.0\u00b0C)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">stress <strong>\u6d4b\u8bd5\u811a\u672c<\/strong><\/h2>\n\n\n\n<p><strong> \u8f93\u5165\u6d4b\u8bd5\u65f6\u95f4\uff0c\u6bcf\u79d2\u949f\u6253\u5370\u5f53\u524dCPU\u6e29\u5ea6 \uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">#!\/bin\/sh\necho -n \"Input test time:\"\nread TIME\necho \"===================STRESS TEST START===================\"\nstress -c 4 --vm 10 --vm-hang 100 -t $TIME &amp;\n\nwhile [ \"$TIME\" -gt 0 ]; do\n\tsensors|grep -E \"Package|Core\"\n\tsleep 1\n\tTIME=$(($TIME-1))\n\techo \"==============================time:$TIME\"\ndone<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u6d4b\u8bd5\u622a\u5c4f<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"432\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2019\/10\/stress_test_screenshot-1024x432.png\" alt=\"\" class=\"wp-image-972\" srcset=\"http:\/\/iqotom.com\/wp-content\/uploads\/2019\/10\/stress_test_screenshot-1024x432.png?v=1585627962 1024w, http:\/\/iqotom.com\/wp-content\/uploads\/2019\/10\/stress_test_screenshot-300x127.png?v=1585627962 300w, http:\/\/iqotom.com\/wp-content\/uploads\/2019\/10\/stress_test_screenshot-768x324.png?v=1585627962 768w, http:\/\/iqotom.com\/wp-content\/uploads\/2019\/10\/stress_test_screenshot-660x278.png?v=1585627962 660w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>stress<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>stress\u662f\u4e00\u4e2alinux\u4e0b\u7684\u538b\u529b\u6d4b\u8bd5\u5de5\u5177\uff0c \u4e3a\u5e0c\u671b\u5b8c\u5168\u5728\u9ad8\u8d1f\u8f7d\u4e0b\u6d4b\u8bd5\u5176\u7cfb\u7edf\u5e76\u76d1\u63a7\u8fd0\u884c\u72b6\u51b5\u7684\u7528\u6237\u800c\u8bbe\u8ba1 \u3002 \u2026 <span class=\"read-more\"><a href=\"http:\/\/iqotom.com\/?p=969\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":973,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,81],"tags":[85],"_links":{"self":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/969"}],"collection":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=969"}],"version-history":[{"count":11,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/969\/revisions"}],"predecessor-version":[{"id":1895,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/969\/revisions\/1895"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/media\/973"}],"wp:attachment":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=969"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}