美文网首页
Stress-ng 压力测试

Stress-ng 压力测试

作者: vivian310 | 来源:发表于2020-11-06 10:39 被阅读0次

    1、源码位置
    https://github.com/ColinIanKing/stress-ng
    2、参数和用法
    -c 2 : 生成2个worker循环调用sqrt()产生cpu压力
    -i 1 : 生成1个worker循环调用sync()产生io压力
    -m 1 : 生成1个worker循环调用malloc()/free()产生内存压力
    -c N :运行N worker CPU压力测试进程
    --cpu-method all :worker从迭代使用30多种不同的压力算法,包括pi, crc16, fft等等
    -tastset N:将压力加到指定核心上
    -d N:运行N worker HDD write/unlink测试
    -i N:运行N worker IO测试

    比如, 从下面可以看出经过30秒的压力后,系统负载从0.00提升至0.57。

    [root@hluo ~]# uptime
     00:14:44 up 18 min,  1 user,  load average: 0.00, 0.01, 0.02
    [root@hluo ~]# stress -c 2 -t 30
    stress: info: [2312] dispatching hogs: 2 cpu, 0 io, 0 vm, 0 hdd
    stress: info: [2312] successful run completed in 30s
    [root@hluo ~]# uptime
     00:15:40 up 19 min,  1 user,  load average: 0.57, 0.18, 0.07
    

    产生2个worker做圆周率算法压力:

    stress-ng -c 2 --cpu-method pi
    

    产生2个worker从迭代使用30多种不同的压力算法,包括pi, crc16, fft等等。

    stress-ng -c 2 --cpu-method all
    

    产生2个worker调用socket相关函数产生压力

    stress-ng --sock 2
    

    产生2个worker读取tsc产生压力

    stress-ng --tsc 2
    

    除了能够产生不同类型的压力,strss-ng还可以将压力指定到特定的cpu上,比如下面的命令将压力指定到cpu 0,2,3,6:

    stress-ng --sock 4 --taskset 0,2-3,6 
    

    相关文章

      网友评论

          本文标题:Stress-ng 压力测试

          本文链接:https://www.haomeiwen.com/subject/okxtbktx.html