I'm writing an application where disk performance is interesting. I previously used an older, mechanical disk and used the technique in this thread to clear the cache before measuring performance:
// Clear cache for benchmarking
sync();
std::ofstream ofs("/proc/sys/vm/drop_caches");
ofs << "3" << std::endl;
ofs.close();
That worked well and gave me expected results - a measured disk sequential read speed of ~100 MB/s when clearing the cache, many times higher when cache was left alone.
The other day I installed an SSD disk, mounted under /media/. After a fresh computer restart, the first couple of measurements are as expected (around 300 MB/s) but when the cache kicks in they are obviously much higher.
My problem now is that the lines of code I previously used have no effect since moving the application to the SSD. Does that cache behave in a different way, maybe? Anything I need to do differently to clear it? The only thing that works now is a computer restart.