Make gclient sync use cpu count for default jobs
- On high core, fast machines, jobs=8 is does not offer good
parallelization. Switch to use number of local cpus.
R=maruel@chromium.org
BUG=
Review URL: https://chromiumcodereview.appspot.com/11140019
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@162072 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index ab45d28..78fa722 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -769,3 +769,17 @@
fix_url('CODE_REVIEW_SERVER')
fix_url('VIEW_VC')
return keyvals
+
+
+def NumLocalCpus():
+ """Returns the number of processors.
+
+ Python on OSX 10.6 raises a NotImplementedError exception.
+ """
+ try:
+ import multiprocessing
+ return multiprocessing.cpu_count()
+ except: # pylint: disable=W0702
+ # Mac OS 10.6 only
+ # pylint: disable=E1101
+ return int(os.sysconf('SC_NPROCESSORS_ONLN'))