Refactor _lp_CPUNUM

This commit is contained in:
Olivier Mengué 2012-08-14 23:24:55 +02:00
parent 1f21d7ff5e
commit 7f5346f953

View File

@ -144,23 +144,12 @@ else
fi
# get cpu number
_lp_cpunum_Linux()
{
grep -c '^[Pp]rocessor' /proc/cpuinfo
}
_lp_cpunum_FreeBSD()
{
sysctl -n hw.ncpu
}
_lp_cpunum_SunOS()
{
kstat -m cpu_info | grep -c "module: cpu_info"
}
_lp_CPUNUM=$(_lp_cpunum_$LP_OS)
# Get cpu count
case "$LP_OS" in
Linux) _lp_CPUNUM=$( nproc || grep -c '^[Pp]rocessor' /proc/cpuinfo ) ;;
FreeBSD) _lp_CPUNUM=$( sysctl -n hw.ncpu ) ;;
SunOS) _lp_CPUNUM=$( kstat -m cpu_info | grep -c "module: cpu_info" ) ;;
esac
# get current load