Reputation: 36597
Roughly speaking, what's the performance of .net code that reads/deletes keys from the Windows registry? Is it akin to file i/o? faster? closer to memory i/o? slower? closer to network i/o? (i can't imagine...just stated for completeness =)
Upvotes: 1
Views: 198
Reputation: 27342
You can't even start to compare network i/o with local file i/o / registry access because there are so many more factors at work.
You could in theory devise some sort of test to compare file reads with registry reads, but I don't think it will be of any benefit. This test could still be flawed because it may depend on which keys you are reading from and other apps that may also be reading the registry in the background.
If you need to access the registry then the time it takes is largely irrelevant because you have no option but to do it anyway - likewise with file i/o.
EDIT:
Quick Test gives the following results:
100,000 registry reads takes 1.81 - 1.89 s
100,000 reads of a 9 byte file takes 19.80 - 20.10 s (so registry is much (~10x) faster:)
Dim sw As New Stopwatch
Dim subkey As RegistryKey
Dim value As String
Dim keyValue As String
sw.Reset()
sw.Start()
For i As Integer = 1 To 100000
keyValue = "SOFTWARE\Codejock Software\Xtreme SuitePro ActiveX v15.0.2"
subkey = Registry.LocalMachine.OpenSubKey(keyValue, False)
value = subkey.GetValue("Installation Directory")
Next
sw.Stop()
Debug.WriteLine("Registry Read:" + sw.ElapsedMilliseconds.ToString)
Dim fileContents As String
sw.Reset()
sw.Start()
For i As Integer = 1 To 100000
fileContents = My.Computer.FileSystem.ReadAllText("C:\scratch\Text.txt")
Next
sw.Stop()
Debug.WriteLine("File Read:" + sw.ElapsedMilliseconds.ToString)
Upvotes: 2