Admin/isatest-statistics
author wenzelm
Fri Dec 29 17:24:46 2006 +0100 (2006-12-29)
changeset 21935 4e20a5397b57
parent 20651 41a63aabea83
permissions -rwxr-xr-x
renamed project to subgraph, improved presentation, avoided unnecessary evaluation of predicate;
wenzelm@20611
     1
#!/usr/bin/env bash
wenzelm@20611
     2
#
wenzelm@20611
     3
# $Id$
wenzelm@20611
     4
# Author: Makarius
wenzelm@20611
     5
#
wenzelm@20611
     6
# DESCRIPTION: Produce statistics from isatest session logs.
wenzelm@20611
     7
wenzelm@20611
     8
ISATEST_LOG=~isatest/log
wenzelm@20611
     9
isatest@20646
    10
## platform settings
isatest@20646
    11
isatest@20646
    12
case $(uname) in
isatest@20646
    13
	SunOS)	
isatest@20646
    14
		ZGREP=xgrep 
isatest@20651
    15
		TE="png color"
isatest@20646
    16
	;;
isatest@20646
    17
	*)	
isatest@20646
    18
		ZGREP=zgrep
isatest@20651
    19
		TE="png"
isatest@20646
    20
	;;
isatest@20646
    21
esac
wenzelm@20611
    22
wenzelm@20611
    23
## diagnostics
wenzelm@20611
    24
wenzelm@20611
    25
PRG="$(basename "$0")"
wenzelm@20611
    26
wenzelm@20611
    27
function usage()
wenzelm@20611
    28
{
wenzelm@20611
    29
  echo
wenzelm@20614
    30
  echo "Usage: $PRG DIR PLATFORM TIMESPAN SESSIONS..."
wenzelm@20611
    31
  echo
wenzelm@20614
    32
  echo "  Produce statistics from isatest session logs, looking TIMESPAN"
wenzelm@20614
    33
  echo "  days into the past.  Outputs .png files into DIR."
wenzelm@20611
    34
  echo
wenzelm@20611
    35
  exit 1
wenzelm@20611
    36
}
wenzelm@20611
    37
wenzelm@20611
    38
function fail()
wenzelm@20611
    39
{
wenzelm@20611
    40
  echo "$1" >&2
wenzelm@20611
    41
  exit 2
wenzelm@20611
    42
}
wenzelm@20611
    43
wenzelm@20611
    44
wenzelm@20611
    45
## arguments
wenzelm@20611
    46
wenzelm@20611
    47
[ "$1" = "-?" ] && usage
wenzelm@20614
    48
[ "$#" -lt "4" ] && usage
wenzelm@20611
    49
wenzelm@20614
    50
DIR="$1"; shift
wenzelm@20611
    51
PLATFORM="$1"; shift
wenzelm@20611
    52
TIMESPAN="$1"; shift
wenzelm@20611
    53
SESSIONS="$@"
wenzelm@20611
    54
wenzelm@20611
    55
wenzelm@20611
    56
## main
wenzelm@20611
    57
wenzelm@20611
    58
ALL_DATA="/tmp/isatest-all$$.dat"
wenzelm@20611
    59
SESSION_DATA="/tmp/isatest$$.dat"
wenzelm@20614
    60
mkdir -p "$DIR" || fail "Bad directory: $DIR"
wenzelm@20611
    61
isatest@20646
    62
$ZGREP "^Finished .*elapsed" \
wenzelm@20614
    63
  $(find "$ISATEST_LOG" -name "isatest-makeall-${PLATFORM}*" -ctime "-${TIMESPAN}") | \
wenzelm@20611
    64
perl -e '
wenzelm@20611
    65
  while (<>) {
wenzelm@20615
    66
    if (m/isatest-makeall-.*-(\d+)-(\d+)-(\d+)-.*:Finished (\S+) \(.*, (\d+):(\d+):(\d+) cpu time\)/) {
wenzelm@20611
    67
        my $year = $1;
wenzelm@20611
    68
        my $month = $2;
wenzelm@20611
    69
        my $day = $3;
wenzelm@20611
    70
        my $name = $4;
wenzelm@20614
    71
        my $time = ($5 * 3600 + $6 * 60 + $7) / 60;
wenzelm@20611
    72
wenzelm@20614
    73
        printf "$name $year-$month-$day %.2f\n", $time;
wenzelm@20611
    74
    }
wenzelm@20611
    75
  }' > "$ALL_DATA"
wenzelm@20611
    76
wenzelm@20611
    77
for SESSION in $SESSIONS
wenzelm@20611
    78
do
wenzelm@20611
    79
  fgrep "$SESSION " "$ALL_DATA" > "$SESSION_DATA"
wenzelm@20611
    80
  gnuplot <<EOF
isatest@20651
    81
set terminal $TE
wenzelm@20614
    82
set output "$DIR/${SESSION}.png"
wenzelm@20614
    83
set xdata time
wenzelm@20614
    84
set timefmt "%Y-%m-%d"
wenzelm@20614
    85
set format x "%d-%b"
wenzelm@20614
    86
set xlabel "$SESSION"
isatest@20646
    87
plot [] [0:] "$SESSION_DATA" using 2:3 smooth sbezier notitle, "$SESSION_DATA" using 2:3 smooth csplines notitle
wenzelm@20611
    88
EOF
wenzelm@20611
    89
done
wenzelm@20611
    90
wenzelm@20611
    91
rm -f "$ALL_DATA" "$SESSION_DATA"