We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
cpu_count()
1 parent 07f57ac commit 91c477fCopy full SHA for 91c477f
share/ruby-install/system.sh
@@ -93,6 +93,25 @@ function detect_downloader()
93
esac
94
}
95
96
+#
97
+# Gets the number of CPU cores.
98
99
+function cpu_count()
100
+{
101
+ local count
102
+
103
+ case "$os_platform" in
104
+ Darwin|*BSD)
105
+ count="$(sysctl -n hw.ncpu)"
106
+ ;;
107
+ *)
108
+ count="$(getconf _NPROCESSORS_ONLN || grep -c ^processor /proc/cpuinfo)"
109
110
+ esac
111
112
+ echo -n "$count"
113
+}
114
115
detect_os
116
detect_sudo
117
detect_package_manager
test/system-tests/cpu_count_test.sh
@@ -0,0 +1,9 @@
1
+. ./test/helper.sh
2
+. ./share/ruby-install/system.sh
3
4
+function test_cpu_count()
5
6
+ assertTrue "did not return a number > 0" '(( $(cpu_count) > 0 ))'
7
8
9
+SHUNIT_PARENT=$0 . $SHUNIT2
0 commit comments