Skip to content

Commit a90b074

Browse files
authored
refactor(build): use dynamic cpu cores to compile code. (#265)
* Modify the default number of threads used for compilation to be the number of CPU logical cores instead of hardcode. * Modify the default number of threads used for compilation on Linux and MAC platforms to be the number of CPU logical cores, rather than hardcode.
1 parent 00ecc4d commit a90b074

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

build.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ PrintParams() {
3939
echo ""
4040
}
4141

42+
if test "$(uname)" = "Linux"; then
43+
declare cpu_num=$(cat /proc/cpuinfo | grep "processor" | wc -l)
44+
elif test "$(uname)" = "Darwin" ; then
45+
declare cpu_num=$(sysctl -n machdep.cpu.thread_count)
46+
fi
4247
declare need_build_jsoncpp=1
4348
declare need_build_libevent=1
4449
declare need_build_boost=1
4550
declare enable_asan=0
4651
declare enable_lsan=0
4752
declare verbose=1
4853
declare codecov=0
49-
declare cpu_num=4
5054
declare test=0
5155

5256
pasres_arguments() {

0 commit comments

Comments
 (0)