linux壓測工具stress和stress-ng安裝和使用

1. 下載

2020/5/16實測以下地址能下載
stress:

https://fossies.org/linux/privat/stress-1.0.4.tar.gz/

stress-ng

https://aur.tuna.tsinghua.edu.cn/packages/stress-ng/

https://kernel.ubuntu.com/~cking/tarballs/stress-ng/

補充:其他工具

 

2. 安裝stress

tar -xzvf stress-1.0.4.tar.gz
cd stress-1.0.4/
./configure
make
make install

如果在嵌入式linux系統上做壓測,可以使用對應的交叉工具鏈編譯,然後再將編譯的目標文件load到開發板,比如rk3308:

tar -xzvf stress-1.0.4.tar.gz
cd stress-1.0.4/
./configure CC=arm-rockchip-linux-gnueabihf-gcc --host=arm-linux --prefix=/home/rick/share/stress-1.0.4/bin
make
make install

用法

stress --help

Usage: stress [OPTION [ARG]] …
-?, --help show this help statement
–version show version statement
-v, --verbose be verbose
-q, --quiet be quiet
-n, --dry-run show what would have been done
-t, --timeout N timeout after N seconds
–backoff N wait factor of N microseconds before work starts
-c, --cpu N spawn N workers spinning on sqrt()
-i, --io N spawn N workers spinning on sync()
-m, --vm N spawn N workers spinning on malloc()/free()
–vm-bytes B malloc B bytes per vm worker (default is 256MB)
–vm-stride B touch a byte every B bytes (default is 4096)
–vm-hang N sleep N secs before free (default none, 0 is inf)
–vm-keep redirty memory instead of freeing and reallocating
-d, --hdd N spawn N workers spinning on write()/unlink()
–hdd-bytes B write B bytes per hdd worker (default is 1GB)

Example: stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s

Note: Numbers may be suffixed with s,m,h,d,y (time) or B,K,M,G (size

3. 安裝stress-ng

tar -xvJf stress-ng-0.10.15.tar.xz
cd stress-ng-0.10.15
make
make install

stress-ng用法:
cpu
stress-ng --cpu 24 --cpu-method pi --cpu-load 100
內存
stress-ng --vm 4 --vm-bytes 12g --vm-method all --vm-keep -v

Example: stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s

Note: Numbers may be suffixed with s,m,h,d,y (time) or B,K,M,G (size).

更多請參考:

https://kernel.ubuntu.com/~cking/stress-ng/

https://kernel.ubuntu.com/~cking/stress-ng/stress-ng.pdf

————————————————
原文鏈接:https://blog.csdn.net/s1421578048/article/details/104262751/

CPU壓力密集型
./stress-ng --cpu 0 --cpu-method pi -t 5m --times &

Mem: 116908K used, 1509556K free, 2152K shrd, 1052K buff, 18616K cached
CPU: 98.8% usr  1.1% sys  0.0% nic  0.0% idle  0.0% io  0.0% irq  0.0% sirq
Load average: 1.23 2.64 3.10 2/99 21624
  PID  PPID USER     STAT   VSZ %VSZ CPU %CPU COMMAND
21621 21620 root     R    12960  0.8   0 92.2 ./stress-ng --cpu 0 --cpu-method p
 

IO壓力密集型
./stress-ng --io 4 --hdd 1 -t 5m --times &

[root@x home]# mpstat -P ALL 5

01:06:10     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
01:06:15     all    0.00    0.00    6.88   93.12    0.00    0.00    0.00    0.00    0.00
01:06:15       0    0.00    0.00    6.88   93.12    0.00    0.00    0.00    0.00    0.00

可以看到 iowait高達93.12
 

參考原文鏈接

其他測試方法實例

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章