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