Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance of reading a registry key?

I'm wondering how long it takes (in milliseconds) to read a registry value from the Windows registry through standard C# libraries. In this case, I'm reading in some proxy settings.

What order of magnitude value should I expect? Are there any good benchmark data available?

I'm running WS2k8 R2 amd64. Bonus points: How impactful is the OS sku/version on this measure?

 using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software/Copium")) 
 { 
      return (string)registryKey.GetValue("BinDir"); 
 } 
like image 632
Kenn Avatar asked Oct 14 '10 02:10

Kenn


1 Answers

I cannot quote numbers as I don't know. But having just read 30 pages in the Windows Internals 5 book about the registry the following noteworthy things that I didn't know became clear.

  • The Registry is transactional and has fail safes to prevent from being corrupted. This can affect performance. Since the transactional level is read committed, reads shouldn't be blocked by writes so they should be performant.

  • The registry is cached in memory (well frequently used values anyway) so if you access a set of keys often the performance should remain stable after the first hit.

like image 184
Preet Sangha Avatar answered Oct 02 '22 18:10

Preet Sangha