void syncAndDropCache(void)
{
int fd;
ssize_t s;
sync();
fd = open("/proc/sys/vm/drop_caches",O_WRONLY);
if(fd<0){
printf("open vm failed\n");
return;
}
s = write(fd,"3",2);
if(s<0){
printf("write vm failed\n");
close(fd);
return;
}
close(fd);
sleep(2);
}
整個 code 在 github: https://github.com/checko/SDReadWriteSpeed
2011年6月21日 星期二
SD Read Write Test -- force drop cache
只是要寫一個SD Card 讀寫檔案的速度測試。
簡單就是: 寫 100M, 紀錄時間,讀100M 紀錄時間。
結果: read 變成超快(200多MB/s),因為 linux cached 住剛剛用過的檔案。所以不會由 SD card 重新讀取。
follow jserv 這一篇 http://blog.linux.org.tw/~jserv/archives/002039.html
手動把 kernel cache drop 掉,再測就OK 了。
drop 的 function 是:
沒有留言:
張貼留言