-
HDD access time.
All HDD (7200, SATA) has access time close to 8ms, but I found strange thing. I have standard drives (2 seagates 7200.10 in RAID 0), and I've wrote application to access to small part of file on my HDD. Access to one file, and get 400 bytes (I tried many files, all the same result), takes... 0ms. More; I've wrote loop, to access different parts of this file, and it gets 9ms for 100 different parts! It's like 0,09 ms for each! I think, there is no mistake: time is in 'ms', not 's', parts are different, not from RAM, and I don't have SSD ;) Maybe someone can tell me, why the 'access time' is about 8ms then?
Code:
Module Module1
Sub Main()
Dim stopw As New Stopwatch
stopw.Start()
Dim strContent As String = Space(400)
For i As Integer = 1 To 100
Dim FileNum As Integer = FreeFile()
FileOpen(FileNum, "Any File Here", OpenMode.Binary, OpenAccess.Read)
FileGet(FileNum, strContent, i * 1000)
FileClose(FileNum)
Next
stopw.Stop()
Console.WriteLine(strContent.Length)
Console.WriteLine("Time : " & stopw.ElapsedMilliseconds & " ms")
Console.Read()
End Sub
End Module
-
Re: HDD access time.
I don't know how accurate Stopwatch is, but it is possible that you are getting some kind of mis-measurement there (but I suspect not massive).
One part of the speed will be due to Windows being clever. Unless the file is huge, when you first request a whole/partial file, Windows will read and store the entire file in memory for a while - so if you use it more than once, from the second time onwards it is not being read from the disk at all.
Another part is the HDD is being clever. Modern drives have built-in RAM (usually about 8MB), and use it to do the same as described above.
In addition to those points, the speed of getting data from a drive is not down to one single factor.. there are several things which need to be done (such as positioning the read-heads, spinning the platters to the start point, etc), all of which take different amounts of time - and depending on what the drive previously did, not all of these things need to be done each time.
As you are using RAID-0, the time to transfer the data will of course be halved.
-
Re: HDD access time.
I'm using each file one time, to aviod reading from memory. Now, with big files (and starting in the middle of them), there is difference: 72ms -> 100 read cycles, each on different position in file. But still it gives below 1ms to read one 'package'. I think, it's beceuse it's one file, and next part isn't far from previous. And I think, It's very good hint, for files processing: you can use small packages (to not wasting RAM), and speed of reading them will be much better, than standard '8ms'.
Btw. RAID 0 won't give you better access time, beceuse it depends on one drive: how fast it can find information. There can be inverse situation: beceuse of data diffusion, there can be lack due to waiting for second read-head (It only increases read speed, after finding data on both drives).
-
Re: HDD access time.
The RAM usage (in Windows and/or the drive) is debatable.. if you have worked with a file recently in any way (such as reading/writing it from another program), it is likely to be stored in RAM. If a prediction was made that you might want the file (like if you opened Explorer to the folder it is in), that could also cause it to be cached.
The fact that you are reading multiple parts of the same file, in chunks, means that less movement is required after the initial movement of the read-heads (the "seek time"). To be an accurate test, you need to be careful about the size you read in each chunk (I don't know how official figures are calculated, so am not sure what this should be), and pick files/parts from various locations on the disk.. not an easy thing to do, as you don't actually know where the files are physically stored.
RAID 0 will give better access time, as not only will the seek time be likely to be reduced (only half the data is stored on each drive, so the heads have half the distance to move), but also the speed of the actual reading ("transfer time") is more than doubled - as not only are each of the drives rotating/reading at 7200 RPM, but also the data is more likely to be stored near the edge of a platter. I think the only component of access time which is not effected is the rotational delay (time to spin the disks to the correct start location), which I suspect has no benefit either way.
Based on a quick search, it seems that 7200 RPM drives have an average access time of about 4ms, so I would expect RAID-0 to be nearer to 2ms. Depending on how 'average' is defined, it could be better still (if it is the mean of best + worst time, the reduced seeking would be significant, as would the increased chance of files being stored on the outer edge of a platter). Assuming the average is based on a certain size, the size of your chunks may reduce it even further.
-
Re: HDD access time.
Use the Frequency and IsHighResolution fields of the Stopwatch class to determine the timing precision. The average system clock isn't precise below 15ms, unless using a high-resolution performance counter.
-
Re: HDD access time.
I think, it's precise, beceuse it gives the same tesult (+- 2ms) for many similar tests.