读写文件速度测试的注意事项
2014-06-19 16:27
399 查看
测试一组文件读写速度时使用如下dd命令,在多次读取时第二次的速度会明显快于第一次,
这是由于内存中缓存了文件内容
$ dd if=/tmp/1 of=/dev/null bs=1024 count=1024
记录了1024+0 的读入
记录了1024+0 的写出
1048576字节(1.0 MB)已复制,0.0754464 秒,13.9 MB/秒
$ dd if=/tmp/1 of=/dev/null bs=1024 count=1024
记录了1024+0 的读入
记录了1024+0 的写出
1048576字节(1.0 MB)已复制,0.0019523 秒,537 MB/秒
使用如下方式来解决这个问题:
$ sudo sh -c " echo 3 > /proc/sys/vm/drop_caches"
$ dd if=/tmp/1 of=/dev/null bs=1024 count=1024
参考:Documentation/sysctl/vm.txt
drop_caches
Writing to this will cause the kernel to drop clean caches, dentries and
inodes from memory, causing that memory to become free.
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation and dirty objects are not freeable, the
user should run `sync' first.
这是由于内存中缓存了文件内容
$ dd if=/tmp/1 of=/dev/null bs=1024 count=1024
记录了1024+0 的读入
记录了1024+0 的写出
1048576字节(1.0 MB)已复制,0.0754464 秒,13.9 MB/秒
$ dd if=/tmp/1 of=/dev/null bs=1024 count=1024
记录了1024+0 的读入
记录了1024+0 的写出
1048576字节(1.0 MB)已复制,0.0019523 秒,537 MB/秒
使用如下方式来解决这个问题:
$ sudo sh -c " echo 3 > /proc/sys/vm/drop_caches"
$ dd if=/tmp/1 of=/dev/null bs=1024 count=1024
参考:Documentation/sysctl/vm.txt
drop_caches
Writing to this will cause the kernel to drop clean caches, dentries and
inodes from memory, causing that memory to become free.
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation and dirty objects are not freeable, the
user should run `sync' first.
相关文章推荐
- MFC文件类CStdioFile读写中文文件的注意事项
- TortoiseSVN使用注意事项之二,不要让SVN影响你浏览文件的速度
- 对彩色YUV视频进行二进制文件读写时候的注意事项
- Go单元测试注意事项及测试单个方法和整个文件的命令
- python2.7中编码问题以及txt文件读写的注意事项
- linux读写文件速度测试
- linux读写文件速度测试
- linux加快串口速度的方法。linux读写不卡机的方法,linux串口接收注意事项,串口窍门,串口加速方法,
- 复赛注意事项:关于文件读写的格式
- python 读写文件 个人 常犯错误 注意事项
- 读写文件速度测试
- WritePrivateProfileString 读写配置文件注意事项
- 读写文件速度测试
- 初学文件操作:软件开机文件读写注意事项
- FILE文件读写注意事项
- 关于标准C文件流读写问题:fopen,fread,fwrite,fclose的一些注意事项
- Linux下各种主要文件系统的读写性能测试 ------------实际系统中的Nand Flash速度测试结果
- LV操作配置文件键值的读写操作注意事项
- 文件读写注意事项
- 测试,RAC添加数据文件时注意事项