- stress 命令主要用来模拟系统负载较高时的场景
ubuntu下安装
zw@zw-pc:apt-get install stress
zw@zw-pc:apt-get install htop #top的增强版,比较直观
zw@zw-pc: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()#产生 N 个进程,每个进程都反复不停的计算随机数的平方根
-i, --io N spawn N workers spinning on sync()#产生 N 个进程,每个进程反复调用 sync() 将内存上的内容写到硬盘上
-m, --vm N spawn N workers spinning on malloc()/free()#产生 N 个进程,每个进程不断分配和释放内存
--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()# 产生 N 个不断执行 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).
- test
没有进行测试之前的情况,可以看到6核心的cpu基本处于空负载状态
产生6个进程消耗cpu资源
消耗2*300M 共600M的mem资源
来源:CSDN
作者:tccxy_
链接:https://blog.csdn.net/juewukun4112/article/details/104790511