I have written a small WPF widget using C# that displays the current CPU activity, RAM used and disk activity as three small percentage type bars. I have used the following PerformanceCounters for this: (diskCounter PerformanceCounter returns current total disk activity in bytes per second)
private void InitialisePerformanceCounters()
{
cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);
totalRam = (int)(new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory / 1024 / 1024);
ramCounter = new PerformanceCounter("Memory", "Available MBytes");
diskCounter = new PerformanceCounter("PhysicalDisk", "Disk Bytes/sec", "_Total", true);
}
The problem is that although I have discovered how to get the total available RAM to calculate a used percentage from, I cannot find out how to read the disk's 'theoretical' maximum data transfer rate. I need this to calculate the percentage of disk transfer rate used. Any help would be greatly appreciated.
2. Click the “Drive” menu, and choose your hard drive. Click the “Block Size” menu, and choose an amount of memory to test. Choose “Read” or “Write,” and enable “Test Burst Rate” to test the maximum burst transfer rate.
A TB is 1048576 megabytes, so, 1048576/90 = 11781 seconds. 111781/60/60= 3.2. Therefore, to successfully recover an entire 1TB HDD averaging at around 90mbs it would take 3.2 hours. This doesn't take into account parsing through data, copying to an external drive, or other people who may be in front of you.
A standard HDD will read and write at typically 80MB/s to 160MB/s, but an SSD reads and writes at between 200MB/s to 550MB/s. Newer technology introduced in recent years offers faster speeds but at a much higher price than a typical storage drive.
A typical 7200 RPM HDD will deliver a read/write speed of 80-160MB/s. On the other hand, a standard SATA SSD will provide a read/write speed of between 200 MB/s to 550 MB/s. At the same time, an NVMe m. 2 SSD can offer speeds exceeding 5000 MB/s.
The only way to do this would be to test it yourself. You could do something like this at the beginning of your application:
byte[] data = new byte[1024];
string path = System.IO.Path.GetTempFileName();
int bytesPerSecond = 0;
using (System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create))
{
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();
for (int i = 0; i < 1024; i++) fs.Write(data, 0, data.Length);
fs.Flush();
watch.Stop();
bytesPerSecond = (int)((data.Length * 1024) / watch.Elapsed.TotalSeconds);
}
System.IO.File.Delete(path);
This does, however, assume that the Temp
directory is on the disk in question. If not, you'll have to create a path on the disk you want to measure. Note that this is measuring write speed, not read speed.
This is somewhat contrived since 1MB is not much data to write, but you could try it with a larger amount of data; the concept is the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With