linux下的CPU、記憶體、IO、網路的壓力測試

來源:互聯網
上載者:User

標籤:cpu mem io network

一、對CPU進行簡單測試:

1、通過bc命令計算特別函數

例:計算圓周率

echo "scale=5000; 4*a(1)" | bc -l -q

MATH LIBRARY 
       If bc is invoked with the -l option, a math library is preloaded and the default  scale  is  set  to  20. 
       The  math  functions  will  calculate their results to the scale set at the time of their call.  The math 
       library defines the following functions: 
       s (x)  The sine of x, x is in radians.    正玄函數 
       c (x)  The cosine of x, x is in radians.  餘玄函數 
       a (x)  The arctangent of x, arctangent returns radians. 反正切函數 
       l (x)  The natural logarithm of x.  log函數(以2為底) 
       e (x)  The exponential function of raising e to the value x.  e的指數函數 
       j (n,x) The bessel function of integer order n of x.   貝塞爾函數 



2、工具二:Super Pi for linux

Super PI是利用CPU的浮點運算能力來計算出π(圓周率),所以目前普遍被超頻玩家用做測試系統穩定性和測試CPU計算完後特定位元圓周率所需的時間。
http://www.super-computing.org/
下載頁:ftp://pi.super-computing.org/

wget ftp://pi.super-computing.org/Linux/super_pi.tar.gz
tar -xzvf super_pi.tar.gz
./super_pi 20
20為位元。表示要算2的多少次方位,如通常要算小數點後1M位。

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/54/4E/wKiom1R-rnXCmbdwAASCjAYEnzQ462.jpg" title="super_pi.png" alt="wKiom1R-rnXCmbdwAASCjAYEnzQ462.jpg" />


二、對記憶體進行簡單測試:

工具:memtester
官方:
http://pyropus.ca/software/memtester/

wget http://pyropus.ca/software/memtester/old-versions/memtester-4.3.0.tar.gz
tar -xzvf memtester-4.3.0.tar.gz
cd memtester-4.3.0
make && make install

用法:Usage: ./memtester [-p physaddrbase [-d device]] <mem>[B|K|M|G] [loops]
例:memtester 1G 5
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/54/4D/wKioL1R-s8yAbf4yAAKk1_Y7zbE003.jpg" title="memtester.png" alt="wKioL1R-s8yAbf4yAAKk1_Y7zbE003.jpg" />


三、對IO進行簡單測試:

1、利用dd來進行測試:

time dd if=/dev/zero of=test bs=1M count=4096

用top和iostat查看wa%及寫硬碟速度

2、使用fio命令進行測試:

FIO是測試IOPS的非常好的工具,用來對硬體進行壓力測試和驗證,支援13種不同的I/O引擎,
包括:sync,mmap, libaio, posixaio, SG v3, splice, null, network, syslet, guasi, solarisaio 等等。

說明:
filename=/dev/sdb1 測試檔案名稱,通常選擇需要測試的盤的data目錄。
direct=1 測試過程繞過機器內建的buffer。使測試結果更真實。
rw=randwrite 測試隨機寫的I/O
rw=randrw 測試隨機寫和讀的I/O
bs=16k 單次io的塊檔案大小為16k
bsrange=512-2048 同上,提定資料區塊的大小範圍
size=5g 本次的測試檔案大小為5g,以每次4k的io進行測試。
numjobs=30 本次的測試線程為30.
runtime=1000 測試時間為1000秒,如果不寫則一直將5g檔案分4k每次寫完為止。
ioengine=psync io引擎使用pync方式
rwmixwrite=30 在混合讀寫的模式下,寫佔30%
group_reporting 關於顯示結果的,匯總每個進程的資訊。
此外
lockmem=1g 只使用1g記憶體進行測試。
zero_buffers 用0初始化系統buffer。
nrfiles=8 每個進程組建檔案的數量。


隨機讀:
fio --filename=/dev/sdb1 --direct=1 --iodepth 1 --thread --rw=randread --ioengine=psync --bs=16k --size=200G --numjobs=10 --runtime=1000 --group_reporting --name=mytest
順序讀:
fio --filename=/dev/sdb1 --direct=1 --iodepth 1 --thread --rw=read --ioengine=psync --bs=16k --size=200G --numjobs=30 --runtime=1000 --group_reporting --name=mytest
隨機寫:
fio --filename=/dev/sdb1 --direct=1 --iodepth 1 --thread --rw=randwrite --ioengine=psync --bs=16k --size=200G --numjobs=30 --runtime=1000 --group_reporting --name=mytest
順序寫:
fio --filename=/dev/sdb1 --direct=1 --iodepth 1 --thread --rw=write --ioengine=psync --bs=16k --size=200G --numjobs=30 --runtime=1000 --group_reporting --name=mytest
混合隨機讀寫:
fio --filename=/dev/sdb1 --direct=1 --iodepth 1 --thread --rw=randrw --rwmixread=70 --ioengine=psync --bs=16k --size=200G --numjobs=30 --runtime=100 --group_reporting --name=mytest --ioscheduler=noop


本文出自 “秋天的童話” 部落格,請務必保留此出處http://wushank.blog.51cto.com/3489095/1585927

linux下的CPU、記憶體、IO、網路的壓力測試

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.