From 1959f973b2cc8b675f044b027bd3cbf60e194e04 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Thu, 18 Jul 2024 05:25:22 -0400 Subject: [PATCH] added another visualization --- tools/viz.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 tools/viz.sh diff --git a/tools/viz.sh b/tools/viz.sh new file mode 100755 index 0000000..d73390e --- /dev/null +++ b/tools/viz.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +merge_diff() { + SA=`stat -c %s A-${ID}.data 2> /dev/null` + SB=`stat -c %s B-${ID}.data 2> /dev/null` + SX=`stat -c %s X-${ID}.data 2> /dev/null` + if [ \( -n "$SA" \) -a \( -n "$SB" \) -a \( -n "$SX" \) ]; then + export RES="$(expr ${SX:-0} / \( $SA + $SB \))" + else + export RES=0 + fi + if [[ $RES -eq 0 ]]; then + export RES="»" + fi +} + +function dynamic() { + local old s t start now + t=0 + start=`date +%s` + while true ; do + s="" + for ((i=10; i<22; i++)) ; do + if [ -f "C-$i.data" ] ; then + s="${s}≡" + else + s="$s " + fi + if [ -f "B-$i.data" ] ; then + s="${s}=" + else + s="$s " + fi + if [ -f "A-$i.data" ] ; then + s="${s}-" + else + s="$s " + fi + if [ -f "X-$i.data" ] ; then + export ID="$i" + merge_diff + s="${s}$RES" + elif [ -f "M-$i.data" ] ; then + s="${s}M" + else + s="$s " + fi + s="$s|" + done + + if [[ "$s" != "$old" ]] ; then + let "t=t+1" + now=`date +%s` + let "now=now-start" + free=`df -m . 2> /dev/null | tail -1 | awk '{print $4}'` + used=`du -m 2> /dev/null | awk '{print $1}' ` + printf "%5d %6d [%s\n" "$t" "$now" "$s ${used}MB (${free}MB free)" + old="$s" + else + # Sleep a little bit: + sleep 1 + fi + done +} + +dynamic