上一篇谈到使用stress工具进行Linux的压力测试,这篇则使用stressapptest工具进行Linux压测。stressapptest是谷歌开源项目用于DDR压力测试,github链接
0.交叉编译
将源码下载到本地编译主机后,需要根据自己的平台交叉编译stressapptest,以下编译build.sh脚本参考:
#!/bin/sh
PWD=$(pwd)
if [ ! -d $PWD/output ];then
mkdir $PWD/output
fi
TOOLCHAIN=/home/xxx/toolchain/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin
export PATH=$TOOLCHAIN:${PATH}
./configure CC="arm-linux-gnueabihf-gcc" --host=arm-linux-gnueabihf --build=x86_64-pc-linux-gnu --prefix=$PWD/output
make
make install
将build.sh脚本拷贝到源码根目录下,执行./build.sh
将在output/bin
下生成目标执行文件stressapptest。注意根据自己实际情况更改
CC、host和build的值。
1.stressapptest用法
-s: number of second to run the application 测试时间
-m: number of memory copy threads to run 复制线程数 (Memory Copy)
-i: number of memory invert threads to run 反转线程数 (Invert Copy)
-c: CRC check CRC 校验 (Data Check)
-C: number of memory CPU stress threads to run CPU压力线程数
-M: Megabytes of ram to run 尽可能测试最大的可用存储空间,(设置超过了memfree,就会被kill)
2.使用举例
下面测试100M内存,测试时间100s
stressapptest -M 100 -s 100
测试成功的log
[root@Sweep:/oem]# stressapptest -M 100 -s 3
1970/01/01-00:03:36(UTC) Log: Commandline - stressapptest -M 100 -s 3
1970/01/01-00:03:36(UTC) Stats: SAT revision 1.0.7_autoconf, 64 bit binary
1970/01/01-00:03:36(UTC) Log: hfh @ RobotServer on Sat May 9 12:17:25 CST 2020 from open source release
1970/01/01-00:03:36(UTC) Log: 1 nodes, 4 cpus.
1970/01/01-00:03:36(UTC) Log: Defaulting to 4 copy threads
1970/01/01-00:03:36(UTC) Log: Prefer plain malloc memory allocation.
1970/01/01-00:03:36(UTC) Log: Using mmap() allocation at 0x7fae511000.
1970/01/01-00:03:36(UTC) Stats: Starting SAT, 100M, 3 seconds
1970/01/01-00:03:37(UTC) Log: Region mask: 0x1
1970/01/01-00:03:42(UTC) Stats: Found 0 hardware incidents
1970/01/01-00:03:42(UTC) Stats: Completed: 6556.00M in 5.01s 1309.88MB/s, with 0 hardware incidents, 0 errors
1970/01/01-00:03:42(UTC) Stats: Memory Copy: 6556.00M at 1309.96MB/s
1970/01/01-00:03:42(UTC) Stats: File Copy: 0.00M at 0.00MB/s
1970/01/01-00:03:42(UTC) Stats: Net Copy: 0.00M at 0.00MB/s
1970/01/01-00:03:42(UTC) Stats: Data Check: 0.00M at 0.00MB/s
1970/01/01-00:03:42(UTC) Stats: Invert Data: 0.00M at 0.00MB/s
1970/01/01-00:03:42(UTC) Stats: Disk: 0.00M at 0.00MB/s
1970/01/01-00:03:42(UTC)
1970/01/01-00:03:42(UTC) Status: PASS - please verify no corrected errors
1970/01/01-00:03:42(UTC)