Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the application method of VB.NET hard disk speed test?

Shulou Source: shulou.com Published: 2022-06-02 22:40:40 09月22日 Update

This article introduces to you what is the application method of VB.NET hard disk speed testing, the content is very detailed, interested friends can refer to, hope to be helpful to you.

What we are most interested in is the continuous read and write speed of the hard disk under the load. In order to measure the average speed more accurately, I decided to write a 1GB file and then read it out. In order not to let more tasks be spent on loops, I first set up a buffer large enough, and then wrote the contents of the buffer to the disk to make the hard drive reach the load. Considering the reading mechanism of Windows, the hard disk test is not accurate. The read part of this program can only be used in * runs. The more times the test is run, the inaccurate the test will be. However, the write test can still keep the accuracy after running many times. Let's do it now.

Create a console project TestHarddisk in VB.NET, and then write the following VB.NET hard disk speed test program in Sub Main.

Sub Main ()

Dim I As Int32

Dim f As New FileStream ("E:\ BigFile.

Big ", FileMode.Create)

Dim fw As New BinaryWriter (f)

Dim fr As New BinaryReader (f)

Dim Size As Int32 = 1024 * 1024 *

1024-1 'File size = 1GB

Dim bufSize As Int32 = 30 * 1024 *

1024 'Buffer Size = 30MB

Dim jLast As Int32 = bufSize-1

Dim j As Int32

Dim Bytes (bufSize) As Byte

Dim StartWrite As DateDate = Date.Now

Console.WriteLine ("Write Start at"

{0} ", StartWrite)

Console.WriteLine ("Creating...")

For I = 0 To Size Step bufSize '1GB

Fw.Write (Bytes)

Next

Dim EndWrite As DateDate = Date.Now

Dim TimePassed As TimeSpan = EndWrite.

Subtract (StartWrite)

Console.WriteLine ("Write End at"

{0} ", EndWrite)

Console.WriteLine ("Time passed: {0}"

TimePassed)

Console.WriteLine ("Speed: {0}", 1000

/ TimePassed.TotalSeconds)

Fw.Flush ()

Dim StartRead As DateDate = Date.Now

Console.WriteLine ("Read Start at"

{0} ", StartRead)

Console.WriteLine ("Reading")

For I = 0 To Size Step bufSize

Bytes = fr.ReadBytes (bufSize)

Next

Dim EndRead As DateDate = Date.Now

TimePassed = EndRead.Subtract (StartRead)

Console.WriteLine ("Read End at {0}", EndRead)

Console.WriteLine ("Time passed:

{0} ", TimePassed)

Console.WriteLine ("Read speed: {0}"

1000 / TimePassed.TotalSeconds)

Console.ReadLine ()

Fw.Close ()

End Sub

The relevant test method of VB.NET hard disk speed test is shown in the above code.

What is the application method of VB.NET hard disk speed testing is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Test hard drive speed method content more run application interest program load help buffer good code task accuracy method boy buddy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Linux MySQL Shulou Technology MariaDB