tests: fix determining number of processors on non-macOS

This commit is contained in:
Moritz Bunkus 2021-07-06 13:36:24 +02:00
parent 133fca6093
commit 4ab5d81ce1
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85

View File

@ -18,13 +18,11 @@ class Controller
end
def get_num_processors
case RUBY_PLATFORM
when /darwin/
np = `/usr/sbin/sysctl -n hw.availcpu`.to_i
else
np = IO.readlines("/proc/cpuinfo").collect { |line| /^processor\s+:\s+(\d+)/.match(line) ? $1.to_i : 0 }.max + 1
np = case RUBY_PLATFORM
when /darwin/ then `/usr/sbin/sysctl -n hw.availcpu`.to_i
else `nproc`.to_i
end
return np > 0 ? np : 1
[ np, 0 ].max + 1
end
def num_threads=(num)