Admin/isatest-statistics
author wenzelm
Tue, 19 Sep 2006 21:49:38 +0200
changeset 20614 948ad402c8a7
parent 20612 706c22b3a8fb
child 20615 0d71cc267e0d
permissions -rwxr-xr-x
target dir; proper time formats;

#!/usr/bin/env bash
#
# $Id$
# Author: Makarius
#
# DESCRIPTION: Produce statistics from isatest session logs.

ISATEST_LOG=~isatest/log


## diagnostics

PRG="$(basename "$0")"

function usage()
{
  echo
  echo "Usage: $PRG DIR PLATFORM TIMESPAN SESSIONS..."
  echo
  echo "  Produce statistics from isatest session logs, looking TIMESPAN"
  echo "  days into the past.  Outputs .png files into DIR."
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


## arguments

[ "$1" = "-?" ] && usage
[ "$#" -lt "4" ] && usage

DIR="$1"; shift
PLATFORM="$1"; shift
TIMESPAN="$1"; shift
SESSIONS="$@"


## main

ALL_DATA="/tmp/isatest-all$$.dat"
SESSION_DATA="/tmp/isatest$$.dat"
mkdir -p "$DIR" || fail "Bad directory: $DIR"

zgrep "^Finished .*elapsed" \
  $(find "$ISATEST_LOG" -name "isatest-makeall-${PLATFORM}*" -ctime "-${TIMESPAN}") | \
perl -e '
  while (<>) {
    if (m/isatest-makeall-\w+-\w+-(\d+)-(\d+)-(\d+)-.*:Finished (\S+) \(.*, (\d+):(\d+):(\d+) cpu time\)/) {
        my $year = $1;
        my $month = $2;
        my $day = $3;
        my $name = $4;
        my $time = ($5 * 3600 + $6 * 60 + $7) / 60;

        printf "$name $year-$month-$day %.2f\n", $time;
    }
  }' > "$ALL_DATA"

for SESSION in $SESSIONS
do
  fgrep "$SESSION " "$ALL_DATA" > "$SESSION_DATA"
  gnuplot <<EOF
set terminal png
set output "$DIR/${SESSION}.png"
set xdata time
set timefmt "%Y-%m-%d"
set format x "%d-%b"
set xlabel "$SESSION"
plot [] [0:] "$SESSION_DATA" using 2:3 title "" smooth sbezier, "$SESSION_DATA" using 2:3 title "" smooth csplines
EOF
done

rm -f "$ALL_DATA" "$SESSION_DATA"