Memory: Use simpler math

This commit is contained in:
Dylan Araps 2016-11-13 22:30:14 +11:00
parent b9606cf611
commit 26809f8eca
1 changed files with 5 additions and 5 deletions

View File

@ -1026,7 +1026,7 @@ get_memory() {
;;
"Mac OS X" | "iPhone OS")
memtotal="$(($(sysctl -n hw.memsize) / 1024 / 1024))"
memtotal="$(($(sysctl -n hw.memsize) / 1024^2))"
memwired="$(vm_stat | awk '/wired/ { print $4 }')"
memactive="$(vm_stat | awk '/active / { printf $3 }')"
memcompressed="$(vm_stat | awk '/occupied/ { printf $5 }')"
@ -1037,12 +1037,12 @@ get_memory() {
case "$distro" in
"NetBSD"*)
memfree="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))"
memtotal="$(($(sysctl -n hw.physmem64) / 1024 / 1024))"
memtotal="$(($(sysctl -n hw.physmem64) / 1024^2))"
;;
*)
memfree="$(($(vmstat | awk 'END{printf $5}') / 1024))"
memtotal="$(($(sysctl -n hw.physmem) / 1024 / 1024))"
memtotal="$(($(sysctl -n hw.physmem) / 1024^2))"
;;
esac
@ -1059,9 +1059,9 @@ get_memory() {
;;
"Haiku")
memtotal="$(($(sysinfo -mem | awk -F '\\/ |)' '{print $2; exit}') / 1024 / 1024))"
memtotal="$(($(sysinfo -mem | awk -F '\\/ |)' '{print $2; exit}') / 1024^2))"
memused="$(sysinfo -mem | awk -F '\\/|)' '{print $2; exit}')"
memused="$((${memused/max} / 1024 / 1024))"
memused="$((${memused/max} / 1024^2))"
;;
esac
memory="${memused}MB / ${memtotal}MB"