Linux内存压力,linux下的CPU、内存、IO、网络的压力测试
一、對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 linuxSuper PI是利用CPU的浮點運算能力來計算出π(圓周率),所以目前普遍被超頻玩家用做測試系統穩定性和測試CPU計算完后特定位數圓周率所需的時間。http://www.super-computing.org/下載頁:ftp://pi.super-computing.org/wgetftp://pi.super-computing.org/Linux/super_pi.tar.gztar -xzvf super_pi.tar.gz./super_pi 2020為位數。表示要算2的多少次方位,如通常要算小數點后1M位。
二、對內存進行簡單測試:
用法:Usage: ./memtester [-p physaddrbase [-d device]] [B|K|M|G] [loops]例:memtester 1G 5
三、對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内存压力,linux下的CPU、内存、IO、网络的压力测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是软件开发模型,常见的软件开发模型有
- 下一篇: 无绳吸尘器对比