From e5fe4abe37a3b2b3d4ce7531db04726aa3d42be9 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Mon, 23 Aug 2010 23:46:34 -0400 Subject: [PATCH] lib/byobu/network, share/man/man1/byobu.1: clean up binary/decimal multipliers for network transfer vs. memory/disk capacities, in accordance with industry standards --- debian/changelog | 4 +++- usr/lib/byobu/network | 19 +++++++++++++------ usr/share/man/man1/byobu.1 | 6 +++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 98311885..7b22138e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ byobu (3.3) unreleased; urgency=low - * UNRELEASED + * lib/byobu/network, share/man/man1/byobu.1: clean up binary/decimal + multipliers for network transfer vs. memory/disk capacities, in + accordance with industry standards -- Dustin Kirkland Mon, 23 Aug 2010 17:52:26 -0400 diff --git a/usr/lib/byobu/network b/usr/lib/byobu/network index 7b1c736a..d97fb94a 100755 --- a/usr/lib/byobu/network +++ b/usr/lib/byobu/network @@ -37,7 +37,6 @@ t2=`date +%s` for i in up down; do cache="$DIR/$PKG.network_$i" t1=`stat -c %Y "$cache"` 2>/dev/null || t1=0 - unit="kB/s" if [ $t2 -le $t1 ]; then rate=0 else @@ -53,15 +52,23 @@ for i in up down; do rate=`echo "$t1" "$t2" "$x1" "$x2" | awk '{printf "%.0f", ($4 - $3) / ($2 - $1) / 1024 }'` if [ "$rate" -lt 0 ]; then rate=0 - elif [ "$rate" -gt 1024 ]; then - rate=`echo "$rate" | awk '{printf "%.1f", $1/1024}'` - unit="MB/s" fi - # Some users want to see bps rather than B/s + # Why 1000 and not 1024? http://en.wikipedia.org/wiki/Data_rate_units case "$NETWORK_UNITS" in bits) rate=`echo "$rate" | awk '{printf "%.0f", $1*8}'` - unit=`echo "$unit" | sed "s:B/s:bps:"` + unit="kbps" + if [ "$rate" -gt 1000 ]; then + rate=`echo "$rate" | awk '{printf "%.1f", $1/1000}'` + unit="Mbps" + fi + ;; + *) + unit="kB/s" + if [ "$rate" -gt 1024 ]; then + rate=`echo "$rate" | awk '{printf "%.1f", $1/1000}'` + unit="MB/s" + fi ;; esac fi diff --git a/usr/share/man/man1/byobu.1 b/usr/share/man/man1/byobu.1 index 229ff077..0614aadd 100644 --- a/usr/share/man/man1/byobu.1 +++ b/usr/share/man/man1/byobu.1 @@ -95,7 +95,11 @@ For example: $ BYOBU_WINDOWS=ssh_sessions byobu .SH UNITS OF MEASURE -byobu uses binary for measurements rather than decimal for KB, MB, and GB. This means multiples of 1024 rather than multiples of 1000, in accordance with JEDEC Standard 100B.01. +byobu uses binary for capacity measurements of KB, MB, GB, and TB. This means multiples of 1024 rather than multiples of 1000, in accordance with JEDEC Standard 100B.01 for disk and memory capacity measurements. See: + * http://en.wikipedia.org/wiki/JEDEC_memory_standards + +byobu uses decimal for measurements of network data transfer, meaning multiple of 1000, rather than 1024. See: + * http://en.wikipedia.org/wiki/Data_rate_units .SH KEYBINDINGS