1、安装
sudo apt-get update sudo apt-get install -y linux-tools-$(uname -r) sudo apt-get install stress
2、命令介绍
stress --help `stress' imposes certain types of compute stress on your system 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压测CPU 100%使用率, 配合htop更直观
未压测前 htop显示
压测所有CPU(16个核, 时间100s)
sudo stress -c 16 -t 100
再次查看htop显示
效果如图
4、指定核心数,以便于达到整体CPU的指定使用率效果
sudo stress --cpu 1 -t 100s
htop图
5、对内存使用率的测试
测试前htop图
stress --vm 3 --vm-bytes 1G --vm-keep -t 100
起3个进程,每个进程分配1G,立即分配,持续100s
测试后htop图
6、对于硬盘使用率的测试
测试前 df -h查看硬盘
stress --hdd 10 --hdd-bytes 10G -t 100
随着时间的推移,使用率会越来越高
7、其他
查看CPU物理信息
# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 36 bits physical, 48 bits virtual CPU(s): 16 On-line CPU(s) list: 0-15 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 165 Model name: Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
参考链接:
https://blog.csdn.net/m0_49448331/article/details/126015207
标签:stress,--,bytes,vm,htop,测试,CPU From: https://www.cnblogs.com/fireblackman/p/16747268.html