zoukankan      html  css  js  c++  java
  • stress工具使用指南和结果分析

    stress介绍

    #stress
    `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).
    

    -? 显示帮助信息

    -v 显示版本号

    -q 不显示运行信息

    -n 显示已完成的指令情况

    -t --timeout N 指定运行N秒后停止

    --backoff N 等待N微妙后开始运行

    -c 产生n个进程 每个进程都反复不停的计算随机数的平方根

    -i 产生n个进程 每个进程反复调用sync(),sync()用于将内存上的内容写到硬盘上

    -m --vm n 产生n个进程,每个进程不断调用内存分配malloc和内存释放free函数

    --vm-bytes B 指定malloc时内存的字节数 (默认256MB)

    --vm-hang N 指定在free钱的秒数

    -d --hadd n 产生n个执行write和unlink函数的进程

    -hadd-bytes B 指定写的字节数

    --hadd-noclean 不unlink

    时间单位可以为秒s,分m,小时h,天d,年y,文件大小单位可以为K,M,G

    stress cpu 测试

    stress测试cpu,是在用户态将cpu 耗尽。

    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #stress -c 1 -t 100
    stress: info: [17223] dispatching hogs: 1 cpu, 0 io, 0 vm, 0 hdd
    

    stress io 测试

    使用stress测试IO,虽然可以创建任意数量的IO进程,但是,可以将 %sys 100%。因为,stress是通过循环执行sync(),使得内核态cpu 100%,但是,stress,没有把w_await svctm 的比例打的很高。

    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #stress  --io 100 -t 100
    stress: info: [130998] dispatching hogs: 0 cpu, 100 io, 0 vm, 0 hdd
    
    [root@jiangyi01.sqa.zmf /home/ahao.mah/gotby/C/c4]
    #ps axu | grep stress |grep -v grep | wc -l
    101
    

    stress mem测试

    stress 测试内存的时候,--vm-bytes 1G --vm-hang 100 这里2个参数是关键!!!!
    --vm-bytes 表示malloc分配多少内存
    --vm-hang 表示malloc分配的内存多少时间后在free()释放掉
    --vm 指定进程数量

    下面例子,就是说,10个进程,同时去malloc分配内存,并且保持100s后再释放内存

    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #stress --vm 10 --vm-bytes 1G --vm-hang 100 --timeout 100s
    stress: info: [32286] dispatching hogs: 0 cpu, 0 io, 10 vm, 0 hdd
    
    
    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #echo "63709272/1024/1024" |bc
    60
    
    


    [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/stress-1.0.4]
    #stress --vm 30 --vm-bytes 1G --vm-hang 50 --timeout 50s
    stress: info: [44047] dispatching hogs: 0 cpu, 0 io, 30 vm, 0 hdd
    
    

    stress 磁盘IO测试

    注意: 我是在/data 目录,这个目录挂载的是raid,总大小:17T

    -d forks
    --hdd forks 产生多个执行write()函数的进程
    --hdd-bytes bytes 指定写的Bytes数,默认是1GB
    --hdd-noclean 不要将写入随机ASCII数据的文件Unlink
    eg:stress -d 1 --hdd-bytes 3G

    解释:-d 1:一个写进程。写入固定大小通过mkstemp()函数写入当前目录;你也可以指定向磁盘中写入固定大小的文件
    这个文件通过调用mkstemp()产生并保存在当前目录下,默认是文件产生后就被执行unlink(清除)操作,
    但是你可以使用“--hdd-bytes”选项将产生的文件全部保存在当前目录下,这会将你的磁盘空间逐步耗尽。
    0

    当只有一个进程在写:

    [root@jiangyi01.sqa.zmf /data]
    #stress --hdd 1 --hdd-bytes 1024G
    stress: info: [130229] dispatching hogs: 0 cpu, 0 io, 0 vm, 1 hdd
    

    测试,提高进程数量为5:

    [root@jiangyi01.sqa.zmf /data]
    #stress --hdd 5 --hdd-bytes 1024G
    stress: info: [26847] dispatching hogs: 0 cpu, 0 io, 0 vm, 5 hdd
    
    

    [root@jiangyi01.sqa.zmf /data]
    #stress --hdd 10 --hdd-bytes 1024G
    stress: info: [31912] dispatching hogs: 0 cpu, 0 io, 0 vm, 10 hdd
    
    [root@jiangyi01.sqa.zmf /home/ahao.mah]
    #ps axu | grep stress | grep -v grep
    root      31912  0.0  0.0   7264   652 pts/0    S+   13:13   0:00 stress --hdd 10 --hdd-bytes 1024G
    root      31913 13.9  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31914 14.5  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    root      31915 14.5  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    root      31916 14.1  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    root      31917 13.9  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31918 14.0  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    root      31919 13.8  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31920 13.9  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31921 13.9  0.0   8164  1120 pts/0    D+   13:13   0:06 stress --hdd 10 --hdd-bytes 1024G
    root      31922 14.0  0.0   8164  1120 pts/0    D+   13:13   0:07 stress --hdd 10 --hdd-bytes 1024G
    
    

    结论:

    1. 可见,--hdd 进程数量,并不是一个干扰因素,这个stress对写磁盘的速度并没有一个控制,直接用最大的压力测试出瓶颈,当瓶颈到达了,进程多几个也是没有什么用,这个估计也是stress的不足之处。
    2. w_await 和svctm 基本一致,说明等待时间和服务时间基本相等。
  • 相关阅读:
    VBA基础一:对象、属性、方法、变量
    js画吊线图
    C++读取硬盘物理序列号-非管理员权限
    什么是句柄?
    2020年WIN7系统的几个问题处理
    静态分析:IDA逆向代码段说明 text、idata、rdata、data
    入门级汇编语法句读
    Ollydbg 单步跟踪F8
    IDA使用之旅(四)
    CSP认证201409-1-相邻数对-(Java)100分
  • 原文地址:https://www.cnblogs.com/muahao/p/6346775.html
Copyright © 2011-2022 走看看