Skip to content

Commit 4ea1fc5

Browse files
Earlopaineregon
authored andcommitted
Improve speed for windows Get-CimInstance
This only fetches a single property which is faster
1 parent d1d29ac commit 4ea1fc5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/concurrent-ruby/concurrent/utility/processor_counter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def compute_physical_processor_count
6969
cores.count
7070
when /mswin|mingw/
7171
# 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
72-
result = run('powershell -command "Get-CimInstance -ClassName Win32_Processor | Select-Object -Property NumberOfCores"')
72+
result = run('powershell -command "Get-CimInstance -ClassName Win32_Processor -Property NumberOfCores | Select-Object -Property NumberOfCores"')
7373
if !result || $?.exitstatus != 0
7474
# fallback to deprecated wmic for older systems
7575
result = run("wmic cpu get NumberOfCores")

0 commit comments

Comments
 (0)