I want to measure/optimize the "cold boot" startup performance of an application, and it’s difficult to do this without an actual reboot, which is obviously not an ideal solution.
Is there a way I could invalidate entire system’s file cache, so that mapped page accesses actually cause a disk access, so that I can measure the time my program takes to start up?
Information:
I pretty much need FSCTL_DISMOUNT_VOLUME‘s functionality, but for the system volume.
At least on Windows 7, it seems that attempting to open a volume handle without
FILE_SHARE_WRITEsharing permissions causes the file system cache to be invalidated, even if the creation fails.Thus I made a program that simply calls
CreateFileto this end.Download the program* from its Base64 version here:
Source
* Just for fun, see if you can figure out what the executable does by disassembling it. It’s not your typical executable. 🙂