summaryrefslogtreecommitdiff
path: root/morphlib/util.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-10-19 15:15:35 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-10-19 15:15:35 +0100
commit263750ef9caf3c591eba8685b7fff00eb66ee41a (patch)
treeb79094c4e40d6c74d5f65e36e62a78f2c379efad /morphlib/util.py
parent04b37aca13ac899bede40bfef19e5c2e1230a75f (diff)
downloadmorph-263750ef9caf3c591eba8685b7fff00eb66ee41a.tar.gz
Add method for deciding how many concurrent make jobs to run.
Diffstat (limited to 'morphlib/util.py')
-rw-r--r--morphlib/util.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/morphlib/util.py b/morphlib/util.py
index 430fdc20..4558d8b8 100644
--- a/morphlib/util.py
+++ b/morphlib/util.py
@@ -44,3 +44,18 @@ def indent(string, spaces=4):
lines = ['%*s%s' % (spaces, '', line) for line in lines]
return '\n'.join(lines)
+
+
+def make_concurrency(cores=None):
+ '''Return the number of concurrent jobs for make.
+
+ This will be given to make as the -j argument.
+
+ '''
+
+ n = multiprocessing.cpu_count() if cores is None else cores
+ # Experimental results (ref. Kinnison) says a factor of 1.5
+ # gives about the optimal result for build times, since much of
+ # builds are I/O bound, not CPU bound.
+ return max(int(n * 1.5 + 0.5), 1)
+