Skip to content

Commit

Permalink
Improve speed for windows Get-CimInstance
Browse files Browse the repository at this point in the history
This only fetches a single property which is faster
  • Loading branch information
Earlopain authored and eregon committed Jun 8, 2024
1 parent d1d29ac commit 4ea1fc5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def compute_physical_processor_count
cores.count
when /mswin|mingw/
# Get-CimInstance introduced in PowerShell 3 or earlier: https://learn.microsoft.com/en-us/previous-versions/powershell/module/cimcmdlets/get-ciminstance?view=powershell-3.0
result = run('powershell -command "Get-CimInstance -ClassName Win32_Processor | Select-Object -Property NumberOfCores"')
result = run('powershell -command "Get-CimInstance -ClassName Win32_Processor -Property NumberOfCores | Select-Object -Property NumberOfCores"')
if !result || $?.exitstatus != 0
# fallback to deprecated wmic for older systems
result = run("wmic cpu get NumberOfCores")
Expand Down

0 comments on commit 4ea1fc5

Please sign in to comment.