mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
This commit is contained in:
parent
956781ac1b
commit
8058b1718f
|
|
@ -139,6 +139,15 @@ sort_effort() {
|
|||
< $tmp sort -rn -k 2
|
||||
}
|
||||
|
||||
#
|
||||
# get processor count, default 8
|
||||
#
|
||||
procs() {
|
||||
if ! (nproc --all || getconf NPROCESSORS_ONLN || getconf _NPROCESSORS_ONLN || grep -c processor /proc/cpuinfo) 2>/dev/null; then
|
||||
echo 8
|
||||
fi
|
||||
}
|
||||
|
||||
declare -a paths=()
|
||||
while [ "${#}" -ge 1 ] ; do
|
||||
|
||||
|
|
@ -207,11 +216,15 @@ heading
|
|||
|
||||
# send paths to effort
|
||||
nPaths=${#paths[@]}
|
||||
nProcs=$(procs)
|
||||
nJobs="\j"
|
||||
for ((i=0; i<nPaths; ++i))
|
||||
do
|
||||
while (( ${nJobs@P} >= nProcs )); do
|
||||
wait -n
|
||||
done
|
||||
effort "${paths[i]}" &
|
||||
done|tee $tmp
|
||||
wait
|
||||
|
||||
# if more than one path, sort and print
|
||||
test "$(wc -l $tmp | awk '{print $1}')" -gt 1 && sort_effort
|
||||
|
|
|
|||
Loading…
Reference in a new issue