linux下内存压力测试——stressapptest
一、简介
stressapptest是Stressfull Application Test的简称。
该软件更多的时候测试的是内存控制器和总线接口,而不是存储单元的功能。测试是会最大化总线和内存的交换量,从而使交换失败的概率会增加。
该软件采用多线程对内存进行拷贝和磁盘接口读写,占用85%的内存块,而且每个线程都是随机进行读写操作,一般每个处理开启2个线程,磁盘也是。
该软件在测试系统接口方面比较好,可以评估一些内存信号完整性或者内存芯片、接口总线及磁盘方面的情况;但是对已经损坏的处理器,物理存储设备不具有检查功能,在该条件下测试,可能会导致系统或驱动崩溃,以及芯片过热。
二、移植
源码下载
git clone https://github.com/stressapptest/stressapptest.git
编译
1)、ubuntu本地使用:
cd stressapptest
./configure
make
sudo make install
2)、移植到arm平台开发板:
cd stressapptest
./configure --target=arm-linux --host=arm-linux --prefix=安装路径 CC=交叉编译工具(xxx-gcc)
make
make install
异常处理
1)、配置过程中可能会报错;
缺少某些库,例如: libaio.a, librt.a (libaio.a: libaio-dev librt.a: libc6-dev);只需在网上查找下对应的库文件,然后连网更新下载便可,然后再编译,一般都可以通过
2)、 编译报错:
os.h:74:29: error: ‘uintptr_t’ has not been declared
...
解决办法:在src/os.h中添加头文件 #include <stdint.h>
之后重新编译即可。
三、测试
把编译出来的stressapptest(在src目录下)拷贝到开发板中进行测试。
测试命令:
可使用stressapptest --help查看参数说明
参考测试命令:stressapptest -s 600 -M 64 -m 8 -C 8 -W
参数说明:
-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)
......
测试结果如下:
/#stressapptest -s 600 -M 64 -m 8 -C 8 -W&
2017/01/01-01:08:59(UTC) Log: Commandline - stressapptest -s 600 -M 64 -m 8 -C 8 -W
2017/01/01-01:08:59(UTC) Stats: SAT revision 1.0.9_autoconf, 32 bit binary
2017/01/01-01:08:59(UTC) Log: helen @ ubuntu on Wed Dec 18 00:45:06 PST 2019 from open source release
2017/01/01-01:08:59(UTC) Log: 1 nodes, 1 cpus.
2017/01/01-01:08:59(UTC) Log: Flooring memory allocation to multiple of 4: 64MB
2017/01/01-01:08:59(UTC) Log: Prefer plain malloc memory allocation.
2017/01/01-01:08:59(UTC) Log: Using mmap() allocation at 0x724d4000.
2017/01/01-01:08:59(UTC) Stats: Starting SAT, 64M, 600 seconds
2017/01/01-01:09:00(UTC) Log: Region mask: 0x1
2017/01/01-01:09:10(UTC) Log: Seconds remaining: 590
2017/01/01-01:09:20(UTC) Log: Seconds remaining: 580
2017/01/01-01:09:30(UTC) Log: Seconds remaining: 570
2017/01/01-01:09:40(UTC) Log: Seconds remaining: 560
2017/01/01-01:09:50(UTC) Log: Seconds remaining: 550
2017/01/01-01:10:00(UTC) Log: Seconds remaining: 540
2017/01/01-01:10:10(UTC) Log: Seconds remaining: 530
2017/01/01-01:10:20(UTC) Log: Seconds remaining: 520
2017/01/01-01:10:30(UTC) Log: Seconds remaining: 510
2017/01/01-01:10:40(UTC) Log: Seconds remaining: 500
2017/01/01-01:10:50(UTC) Log: Seconds remaining: 490
2017/01/01-01:11:00(UTC) Log: Seconds remaining: 480
2017/01/01-01:11:10(UTC) Log: Seconds remaining: 470
2017/01/01-01:11:20(UTC) Log: Seconds remaining: 460
2017/01/01-01:11:30(UTC) Log: Seconds remaining: 450
2017/01/01-01:11:40(UTC) Log: Seconds remaining: 440
2017/01/01-01:11:50(UTC) Log: Seconds remaining: 430
2017/01/01-01:12:00(UTC) Log: Seconds remaining: 420
2017/01/01-01:12:10(UTC) Log: Seconds remaining: 410
2017/01/01-01:12:20(UTC) Log: Seconds remaining: 400
2017/01/01-01:12:30(UTC) Log: Seconds remaining: 390
2017/01/01-01:12:40(UTC) Log: Seconds remaining: 380
2017/01/01-01:12:50(UTC) Log: Seconds remaining: 370
2017/01/01-01:13:00(UTC) Log: Seconds remaining: 360
2017/01/01-01:13:10(UTC) Log: Seconds remaining: 350
2017/01/01-01:13:20(UTC) Log: Seconds remaining: 340
2017/01/01-01:13:30(UTC) Log: Seconds remaining: 330
2017/01/01-01:13:40(UTC) Log: Seconds remaining: 320
2017/01/01-01:13:50(UTC) Log: Seconds remaining: 310
2017/01/01-01:14:00(UTC) Log: Seconds remaining: 300
2017/01/01-01:14:10(UTC) Log: Seconds remaining: 290
2017/01/01-01:14:20(UTC) Log: Seconds remaining: 280
2017/01/01-01:14:30(UTC) Log: Seconds remaining: 270
2017/01/01-01:14:40(UTC) Log: Seconds remaining: 260
2017/01/01-01:14:50(UTC) Log: Seconds remaining: 250
2017/01/01-01:15:00(UTC) Log: Seconds remaining: 240
2017/01/01-01:15:10(UTC) Log: Seconds remaining: 230
2017/01/01-01:15:20(UTC) Log: Seconds remaining: 220
2017/01/01-01:15:30(UTC) Log: Seconds remaining: 210
2017/01/01-01:15:40(UTC) Log: Seconds remaining: 200
2017/01/01-01:15:50(UTC) Log: Seconds remaining: 190
2017/01/01-01:16:00(UTC) Log: Seconds remaining: 180
2017/01/01-01:16:10(UTC) Log: Seconds remaining: 170
2017/01/01-01:16:20(UTC) Log: Seconds remaining: 160
2017/01/01-01:16:30(UTC) Log: Seconds remaining: 150
2017/01/01-01:16:40(UTC) Log: Seconds remaining: 140
2017/01/01-01:16:50(UTC) Log: Seconds remaining: 130
2017/01/01-01:17:00(UTC) Log: Seconds remaining: 120
2017/01/01-01:17:10(UTC) Log: Seconds remaining: 110
2017/01/01-01:17:20(UTC) Log: Seconds remaining: 100
2017/01/01-01:17:30(UTC) Log: Seconds remaining: 90
2017/01/01-01:17:40(UTC) Log: Seconds remaining: 80
2017/01/01-01:17:50(UTC) Log: Seconds remaining: 70
2017/01/01-01:18:00(UTC) Log: Seconds remaining: 60
2017/01/01-01:18:10(UTC) Log: Seconds remaining: 50
2017/01/01-01:18:20(UTC) Log: Seconds remaining: 40
2017/01/01-01:18:30(UTC) Log: Seconds remaining: 30
2017/01/01-01:18:40(UTC) Log: Seconds remaining: 20
2017/01/01-01:18:50(UTC) Log: Seconds remaining: 10
2017/01/01-01:19:47(UTC) Stats: Found 0 hardware incidents
2017/01/01-01:19:47(UTC) Stats: Completed: 38996.00M in 647.38s 60.24MB/s, with 0 hardware incidents, 0 errors
2017/01/01-01:19:47(UTC) Stats: Memory Copy: 38996.00M at 64.98MB/s
2017/01/01-01:19:47(UTC) Stats: File Copy: 0.00M at 0.00MB/s
2017/01/01-01:19:47(UTC) Stats: Net Copy: 0.00M at 0.00MB/s
2017/01/01-01:19:47(UTC) Stats: Data Check: 0.00M at 0.00MB/s
2017/01/01-01:19:47(UTC) Stats: Invert Data: 0.00M at 0.00MB/s
2017/01/01-01:19:47(UTC) Stats: Disk: 0.00M at 0.00MB/s
2017/01/01-01:19:47(UTC)
2017/01/01-01:19:47(UTC) Status: PASS - please verify no corrected errors
2017/01/01-01:19:47(UTC)