想测试一下我的ssd硬盘能达到多少的iops,但是读写的时候因为linux系统会自动将读写操作进行cache,也就没法真实的验证性能了,有没有办法可以把这个特性先关闭? 写操作还好办,可以每次写入之后调用fsync强制写入磁盘,读取有类似的方法么?
补充一下,我不是想直接用现有的工具进行测试,我是自己写了一个读写io的程序(c++),想测试一下对应的iops
巴扎黑2017-04-17 13:26:08
I haven’t found a way to completely close it. The read cache can be temporarily cleared by echo 3 > /proc/sys/vm/drop_caches
迷茫2017-04-17 13:26:08
Add parameters after the dd command. You can Google for details. Or, the test data is twice the memory
PHP中文网2017-04-17 13:26:08
time dd if=/dev/zero of=test bs=64k count=512 oflag=dsync
Parameter explanation:
if input file
of output file
bs The number of bytes read and written at one time
count The number of times the data block is written, it can also be set to 512.
oflag=dsync forces writing to the physical hard disk every time, that is, not writing to the cache, but writing directly to the hard disk
After execution, a 32M (64*512) test file will be generated in the current directory.
The solid state drive reaches 70MB/second, and the mechanical hard drive is estimated to be about 2MB/second.