From owner-svn-soc-all@FreeBSD.ORG Thu Jun 21 22:02:07 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 033331065674 for ; Thu, 21 Jun 2012 22:02:05 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 21 Jun 2012 22:02:05 +0000 Date: Thu, 21 Jun 2012 22:02:05 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120621220205.033331065674@hub.freebsd.org> Cc: Subject: socsvn commit: r238107 - soc2012/rudot/aux X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 22:02:07 -0000 Author: rudot Date: Thu Jun 21 22:02:04 2012 New Revision: 238107 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238107 Log: plotting of collected data Deleted: soc2012/rudot/aux/plot.gnuplot Modified: soc2012/rudot/aux/psSum.sh Modified: soc2012/rudot/aux/psSum.sh ============================================================================== --- soc2012/rudot/aux/psSum.sh Thu Jun 21 21:47:08 2012 (r238106) +++ soc2012/rudot/aux/psSum.sh Thu Jun 21 22:02:04 2012 (r238107) @@ -10,17 +10,47 @@ user_pcpu() { - ps -U "$1" -o %cpu= | awk 'BEGIN{total = 0}{total = total + $1}END{print total}' + ps -U "$1" -o %cpu= | awk ' + BEGIN {total = 0} + {total = total + $1} + END {print total}' } sort_results() { cat $FILE_UNSORTED | tr : "\t" | sort > $FILE_SORTED rm $FILE_UNSORTED +} + +finalize() +{ + sort_results + command -v gnuplot > /dev/null && plot_graph exit 0 } -trap sort_results SIGINT +plot_graph() +{ + XLIMITA=`echo $PCPU_MIN | awk ' + { + if (int($1) == $1) print int($1) - 1; + else print int($1) + }'` + + XLIMITB=`echo $PCPU_MAX | awk '{print int($1) + 1}'` + + gnuplot > plot.eps <<-EOF + set term postscript eps enhanced color + set style line 1 lt 1 lw 1 + set xlabel "CPU percentage" + set ylabel "frequency" + set yrange [0:] + set xrange [${XLIMITA}:${XLIMITB}] + plot "$FILE_SORTED" using 1:2 with imp ls 1 title '' + EOF +} + +trap finalize SIGINT echo "Type [Ctrl + c] to exit" echo "Scanning..." @@ -28,6 +58,19 @@ while : do PCPU=`user_pcpu "$USER"` + + [ -z "$PCPU_MIN" ] && PCPU_MIN=$PCPU + [ -z "$PCPU_MAX" ] && PCPU_MAX=$PCPU + PCPU_MIN_MAX=`echo $PCPU_MIN $PCPU_MAX $PCPU | awk ' + { + if ($1 < $3) min = $1; else min = $3; + if ($2 > $3) max = $2; else max = $3; + print min ":" max + }'` + read PCPU_MIN PCPU_MAX <<-EOF + `IFS=:; echo $PCPU_MIN_MAX` + EOF + LINE=`cat $FILE_UNSORTED 2> /dev/null | grep "^${PCPU}:"` if [ -n "$LINE" ]; then