From 73451a291d57019a52b0a3f211c2e199d5ac7dfe Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Thu, 23 Nov 2017 00:30:22 -0500 Subject: num_jobs will be based on the number of CPUs detected to make sure parallel jobs can fill the queue. --- src/engine/SCons/JobTests.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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 -- cgit v0.12