CPU: Update comments

This commit is contained in:
Dylan Araps 2016-12-14 11:40:29 +11:00
parent 5a6a3d7e5b
commit f7686ee8e8

View file

@ -727,7 +727,7 @@ get_cpu() {
case "$os" in case "$os" in
"Linux" | "Windows") "Linux" | "Windows")
# Get cpu name # Get CPU name
case "$distro" in case "$distro" in
"Android"*) cpu="$(getprop ro.product.board)" ;; "Android"*) cpu="$(getprop ro.product.board)" ;;
*) cpu="$(awk -F ': | @' '/model name|Processor/ {printf $2; exit}' /proc/cpuinfo)" ;; *) cpu="$(awk -F ': | @' '/model name|Processor/ {printf $2; exit}' /proc/cpuinfo)" ;;
@ -736,7 +736,7 @@ get_cpu() {
speed_dir="/sys/devices/system/cpu/cpu0/cpufreq" speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
temp_dir="/sys/class/hwmon/hwmon0/temp1_input" temp_dir="/sys/class/hwmon/hwmon0/temp1_input"
# Get cpu speed # Get CPU speed
if [[ -d "$speed_dir" ]]; then if [[ -d "$speed_dir" ]]; then
# Fallback to bios_limit if $speed_type fails. # Fallback to bios_limit if $speed_type fails.
speed="$(< "${speed_dir}/${speed_type}")" || \ speed="$(< "${speed_dir}/${speed_type}")" || \
@ -749,14 +749,14 @@ get_cpu() {
speed="$((speed / 100))" speed="$((speed / 100))"
fi fi
# Get cpu temp # Get CPU temp
if [[ "$cpu_temp" == "on" && -f "$temp_dir" ]]; then if [[ "$cpu_temp" == "on" && -f "$temp_dir" ]]; then
temp="$(< "$temp_dir")" temp="$(< "$temp_dir")"
temp="$((temp * 100 / 10000))" temp="$((temp * 100 / 10000))"
temp="[${temp/${temp: -1}}.${temp: -1}°C]" temp="[${temp/${temp: -1}}.${temp: -1}°C]"
fi fi
# Show/hide hyperthreaded cores # Get CPU cores
case "$cpu_cores" in case "$cpu_cores" in
"logical" | "on") cores="$(grep -c "^processor" /proc/cpuinfo)" ;; "logical" | "on") cores="$(grep -c "^processor" /proc/cpuinfo)" ;;
"physical") cores="$(grep "^core id" /proc/cpuinfo | sort -u | wc -l)" ;; "physical") cores="$(grep "^core id" /proc/cpuinfo | sort -u | wc -l)" ;;
@ -766,7 +766,7 @@ get_cpu() {
"Mac OS X") "Mac OS X")
cpu="$(sysctl -n machdep.cpu.brand_string)" cpu="$(sysctl -n machdep.cpu.brand_string)"
# Show/hide hyperthreaded cores # Get CPU cores
case "$cpu_cores" in case "$cpu_cores" in
"logical" | "on") cores="$(sysctl -n hw.logicalcpu_max)" ;; "logical" | "on") cores="$(sysctl -n hw.logicalcpu_max)" ;;
"physical") cores="$(sysctl -n hw.physicalcpu_max)" ;; "physical") cores="$(sysctl -n hw.physicalcpu_max)" ;;
@ -801,20 +801,20 @@ get_cpu() {
;; ;;
"BSD") "BSD")
# Get cpu name # Get CPU name
cpu="$(sysctl -n hw.model)" cpu="$(sysctl -n hw.model)"
cpu="${cpu/[0-9]\.*}" cpu="${cpu/[0-9]\.*}"
cpu="${cpu/ @*}" cpu="${cpu/ @*}"
# Get cpu speed # Get CPU speed
speed="$(sysctl -n hw.cpuspeed)" speed="$(sysctl -n hw.cpuspeed)"
[[ -z "$speed" ]] && speed="$(sysctl -n hw.clockrate)" [[ -z "$speed" ]] && speed="$(sysctl -n hw.clockrate)"
speed="$((speed / 100))" speed="$((speed / 100))"
# Get cpu cores # Get CPU cores
cores="$(sysctl -n hw.ncpu)" cores="$(sysctl -n hw.ncpu)"
# Get cpu temp # Get CPU temp
if [[ "$cpu_temp" == "on" ]]; then if [[ "$cpu_temp" == "on" ]]; then
case "$kernel_name" in case "$kernel_name" in
"FreeBSD"* | "DragonFly"*) "FreeBSD"* | "DragonFly"*)
@ -830,17 +830,17 @@ get_cpu() {
;; ;;
"Solaris") "Solaris")
# Get cpuname # Get CPU name
cpu="$(psrinfo -pv)" cpu="$(psrinfo -pv)"
cpu="${cpu//*$'\n'}" cpu="${cpu//*$'\n'}"
cpu="${cpu/[0-9]\.*}" cpu="${cpu/[0-9]\.*}"
cpu="${cpu/ @*}" cpu="${cpu/ @*}"
# Get cpu speed # Get CPU speed
speed="$(psrinfo -v | awk '/operates at/ {print $6; exit}')" speed="$(psrinfo -v | awk '/operates at/ {print $6; exit}')"
speed="$((speed / 100))" speed="$((speed / 100))"
# Show/hide hyperthreaded cores # Get CPU cores
case "$cpu_cores" in case "$cpu_cores" in
"logical" | "on") cores="$(kstat -m cpu_info | grep -c -F "chip_id")" ;; "logical" | "on") cores="$(kstat -m cpu_info | grep -c -F "chip_id")" ;;
"physical") cores="$(psrinfo -p)" ;; "physical") cores="$(psrinfo -p)" ;;
@ -848,11 +848,16 @@ get_cpu() {
;; ;;
"Haiku") "Haiku")
# Get CPU name
cpu="$(sysinfo -cpu | awk -F '\\"' '/CPU #0/ {print $2}')" cpu="$(sysinfo -cpu | awk -F '\\"' '/CPU #0/ {print $2}')"
cpu="${cpu/@*}" cpu="${cpu/@*}"
# Get CPU speed
speed="$(sysinfo -cpu | awk '/running at/ {print $NF; exit}')" speed="$(sysinfo -cpu | awk '/running at/ {print $NF; exit}')"
speed="${speed/MHz}" speed="${speed/MHz}"
speed="$((speed / 100))" speed="$((speed / 100))"
# Get CPU cores
cores="$(sysinfo -cpu | grep -c -F 'CPU #')" cores="$(sysinfo -cpu | grep -c -F 'CPU #')"
;; ;;
esac esac
@ -906,9 +911,7 @@ get_cpu() {
cpu="${cpu/Core? Duo }" cpu="${cpu/Core? Duo }"
cpu="${cpu/AMD }" cpu="${cpu/AMD }"
case "$cpu_shorthand" in [[ "$cpu_shorthand" == "tiny" ]] && cpu="${cpu/@*}"
"tiny") cpu="${cpu/@*}" ;;
esac
;; ;;
esac esac
} }