Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster CPU Name Retrieval Method #167

Merged
merged 4 commits into from
Jan 31, 2023

Conversation

Carterpersall
Copy link
Contributor

  • Replaces the CIM method with one that uses the registry
    • Uses the keys ~MHz and ProcessorNameString at HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0
      • Uses [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computername).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0") and GetValue() to get the registry keys much faster than using Get-ItemProperty
    • Currently doesn't round the frequency as rounding is slow

Speed :

  • PowerShell 5:
    • 11.71ms → 4.99ms
      • 2.35x Faster
  • PowerShell 7:
    • 12.18ms → 4.23ms
      • 2.88x Faster

Bottlenecked Speed:

  • PowerShell 5:
    • 39.25ms → 20.28ms
      • 1.94x Faster
  • PowerShell 7:
    • 29.43ms → 15.17ms
      • 1.94x Faster

- Replaces the CIM method with one that uses the registry
  - Uses `[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computername).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0")` to get a registry key much faster than `Get-ItemProperty`
  - Currently doesn't round the frequency as rounding is slow
@Carterpersall Carterpersall changed the title Faster CPU retrieval method Faster CPU Name retrieval method Nov 8, 2022
@Carterpersall Carterpersall changed the title Faster CPU Name retrieval method Faster CPU Name Retrieval Method Nov 8, 2022
@rashil2000
Copy link
Member

It seems to be showing frequency twice:
image

Also, please don't use camelcase. Stick to small case.

Carterpersall and others added 2 commits January 12, 2023 10:56
Attempt to fix bug with duplication of frequency by removing whitespace in split command
@rashil2000 rashil2000 merged commit 62ede34 into lptstr:master Jan 31, 2023
@rashil2000
Copy link
Member

Uses [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computername).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0") and GetValue() to get the registry keys much faster than using Get-ItemProperty

@Carterpersall off topic but there are a bunch of other places where we use Get-ItemProperty to read the registry - do you think we should replace them too?

@Carterpersall Carterpersall deleted the Optimize-CPU branch January 31, 2023 13:32
@Carterpersall
Copy link
Contributor Author

Uses [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computername).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0") and GetValue() to get the registry keys much faster than using Get-ItemProperty

@Carterpersall off topic but there are a bunch of other places where we use Get-ItemProperty to read the registry - do you think we should replace them too?

Might be worth checking if replacing them causes as much of a speed improvement as this does

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants