存储速度测试
时间:2024-02-28
使用c++的fstream类的write接口编写程序测试写入速度;
环境:
电脑一:单磁盘Samsung SSD 860EVO 1TB
电脑二:阵列磁盘RAID0, 三星990pro 1TB两个
测试工具:CrystalDiskMark 8
电脑一:
工具测试速度和代码测试速度一致,都是500MB左右,未测试二级缓存。
电脑二:
工具测试结果:(1MB的块,一共写1GB,运行五次)
使用下面代码:测试速度只有1GB/s
std::fstream file;
file.open(fiel_path.c_str(), std::ios::out);
file.write(data, DATA_SIZE);
使用下面代码:测试速度有3GB/s
std::fstream file;
file.open(fiel_path.c_str(), std::ios::out| std::ios::binary);
file.write(data, DATA_SIZE);
使用下面代码:测试速度有3.9GB/s
std::fstream file;
file.open(fiel_path.c_str(), std::ios::out| std::ios::binary);
file.write(data, DATA_SIZE);
file.flush();
使用多线程同时写多个文件:速度可以达到7.9GB/s
目前测试最高就只能到工具测试出来的单线程单队列的速度。
多线程多队列的速度还无法实现。可能是接口的问题,调用一些windows底层接口或许可以达到。
补充
m2口磁盘写入仍存在缓外掉速问题,可考虑使用PCIE4.0或者PCIE5.0口的ssd盘,这个磁盘暂时没有到还没测试