mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-20 21:43:19 -07:00
Optimizing previous work
This commit is contained in:
parent
0dbb93b961
commit
053030050b
3 changed files with 14 additions and 12 deletions
|
@ -24,11 +24,11 @@ __cpu_count_detail() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__cpu_count() {
|
__cpu_count() {
|
||||||
if [ $(uname) = "FreeBSD" ]; then
|
local c
|
||||||
c=$(sysctl -n hw.ncpu)
|
c=$(getconf _NPROCESSORS_ONLN 2>/dev/null || \
|
||||||
else
|
grep -ci "^processor" /proc/cpuinfo || \
|
||||||
local c
|
sysctl -n hw.ncpu)
|
||||||
c=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo)
|
|
||||||
fi
|
|
||||||
[ "$c" = "1" ] || printf "%sx" "$c"
|
[ "$c" = "1" ] || printf "%sx" "$c"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# vi: syntax=sh ts=4 noexpandtab
|
||||||
|
|
|
@ -25,11 +25,8 @@ __cpu_freq_detail() {
|
||||||
|
|
||||||
__cpu_freq() {
|
__cpu_freq() {
|
||||||
local hz freq count
|
local hz freq count
|
||||||
if [ $(uname) = "FreeBSD" ]; then
|
|
||||||
hz=$(sysctl -n machdep.tsc_freq)
|
if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" ]; then
|
||||||
fpdiv $hz "1000000000" 1
|
|
||||||
freq="$_RET"
|
|
||||||
elif [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" ]; then
|
|
||||||
read hz < /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
|
read hz < /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
|
||||||
fpdiv $hz "1000000" 1 # 1Ghz
|
fpdiv $hz "1000000" 1 # 1Ghz
|
||||||
freq="$_RET"
|
freq="$_RET"
|
||||||
|
@ -37,7 +34,6 @@ __cpu_freq() {
|
||||||
if egrep -q -s -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo; then
|
if egrep -q -s -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo; then
|
||||||
freq=$(egrep -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo | awk -F"[:.]" '{ printf "%01.1f", $2 / 1000 }')
|
freq=$(egrep -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo | awk -F"[:.]" '{ printf "%01.1f", $2 / 1000 }')
|
||||||
else
|
else
|
||||||
# Must scale frequency by number of processors, if counting bogomips
|
|
||||||
count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo)
|
count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo)
|
||||||
freq=$(egrep -i -m 1 "^bogomips" /proc/cpuinfo | awk -F"[:.]" '{ print $2 }')
|
freq=$(egrep -i -m 1 "^bogomips" /proc/cpuinfo | awk -F"[:.]" '{ print $2 }')
|
||||||
freq=$(printf "%s %s" "$freq" "$count" | awk '{printf "%01.1f\n", $1/$2/1000}')
|
freq=$(printf "%s %s" "$freq" "$count" | awk '{printf "%01.1f\n", $1/$2/1000}')
|
||||||
|
@ -45,7 +41,11 @@ __cpu_freq() {
|
||||||
elif hz=$(sysctl -n hw.cpufrequency 2>/dev/null); then
|
elif hz=$(sysctl -n hw.cpufrequency 2>/dev/null); then
|
||||||
fpdiv $hz "1000000000" 1 # 1Ghz
|
fpdiv $hz "1000000000" 1 # 1Ghz
|
||||||
freq="$_RET"
|
freq="$_RET"
|
||||||
|
elif hz=$(sysctl -n machdep.tsc_freq 2>/dev/null); then
|
||||||
|
fpdiv $hz "1000000000" 1
|
||||||
|
freq="$_RET"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "$freq" ] || return
|
[ -n "$freq" ] || return
|
||||||
color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$ICON_GHz"; color --
|
color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$ICON_GHz"; color --
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,3 +40,5 @@ __users() {
|
||||||
rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/users"*
|
rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/users"*
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# vi: syntax=sh ts=4 noexpandtab
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue