最後更新: 2019-05-15
介紹
stress 是系統壓力測試工具
它有兩個版本
- stress (CPU, memory, I/O, and disk stress)
-
stress-ng
- Cache thrashing,
- Socket stressing,
- Context switching,
- Process creation & termination
- CPU specific stress tests
stress
Opts
-n, --dry-run # show what would have been done
-t, --timeout N # timeout after N seconds (Unit: s,m,h,d,y)
測試什麼
-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: 256Mbyte; Unit: b, k, m,g)
--vm-hang N # sleep N secs before free
-d, --hdd N # spawn N workers spinning on write()/unlink()
--hdd-bytes B # write B bytes per hdd worker (default is 1GB)
Example
[1] 60 second 100% loading on 1 cpu core
stress -t 60 -c 1
[2] 60 second 1 G memory stress test
stress -t 60 --vm 1 --vm-bytes 1G
stress: info: [11816] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd stress: info: [11816] successful run completed in 60s
stress-ng
Install
apt-get install stress-ng
Testing
stress-ng -c 4
stress-ng: info: [10422] defaulting to a 86400 second run per stressor stress-ng: info: [10422] dispatching hogs: 4 cpu stress-ng: info: [10422] cache allocate: default cache size: 2048K
# 1 worker with 200 MBytes
stress-ng -m 1 --vm-bytes 200m