If you have the question of executing disc reads/writes directly against the device and avoid file cache of the OS you're welcome to continue reading this post.
Intro
Assume you're creating a disk benchmark app you want to execute on Windows and macOS (and might be any other platform) and in your .NET Core project come up with a solution similar to the below C# code snippet:
var sw = new Stopwatch();
var file = new FileStream("C:\\testfile.dat", FileMode.CreateNew);
var buffer = new byte[1024 * 1024 * 1024];
var rand = new Random();
rand.NextBytes(buffer);
sw.Restart();
file.Write(buffer, 0, blockSize);
file.Flush();
sw.Stop();
- you create a file a get an instance of
FileStream, write a randomized byte array to it and measure the time it took to complete the write.