summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Moody <dmoody256@gmail.com>2017-11-23 05:30:22 (GMT)
committerDaniel Moody <dmoody256@gmail.com>2017-11-23 05:30:22 (GMT)
commit73451a291d57019a52b0a3f211c2e199d5ac7dfe (patch)
tree43edbf1bc956bcd03beaaf7d398a1832c4c0eacd
parent0b8a2ac3b7f2eea24a374600ac617a76c6c1cae1 (diff)
downloadSCons-73451a291d57019a52b0a3f211c2e199d5ac7dfe.zip
SCons-73451a291d57019a52b0a3f211c2e199d5ac7dfe.tar.gz
SCons-73451a291d57019a52b0a3f211c2e199d5ac7dfe.tar.bz2
num_jobs will be based on the number of CPUs detected to make sure parallel jobs can fill the queue.
-rw-r--r--src/engine/SCons/JobTests.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/engine/SCons/JobTests.py b/src/engine/SCons/JobTests.py
index dd2c7aa..6ae8e92 100644
--- a/src/engine/SCons/JobTests.py
+++ b/src/engine/SCons/JobTests.py
@@ -27,17 +27,40 @@ import random
import math
import sys
import time
+import os
import TestUnit
import SCons.Job
+def get_cpu_nums():
+ # Linux, Unix and MacOS:
+ if hasattr( os, "sysconf" ):
+ if "SC_NPROCESSORS_ONLN" in os.sysconf_names:
+ # Linux & Unix:
+ ncpus = os.sysconf( "SC_NPROCESSORS_ONLN" )
+ if isinstance(ncpus, int) and ncpus > 0:
+ return ncpus
+ else: # OSX:
+ return int( os.popen2( "sysctl -n hw.ncpu")[1].read() )
+ # Windows:
+ if "NUMBER_OF_PROCESSORS" in os.environ:
+ ncpus = int( os.environ[ "NUMBER_OF_PROCESSORS" ] );
+ if ncpus > 0:
+ return ncpus
+ return 1 # Default
+
# a large number
num_sines = 10000
# how many parallel jobs to perform for the test
-num_jobs = 11
+num_jobs = get_cpu_nums()*2
+
+# in case we werent able to detect num cpus for this test
+# just make a hardcoded suffcient large number, though not future proof
+if(num_jobs == 2):
+ num_jobs = 33
# how many tasks to perform for the test
num_tasks = num_jobs*5