Admin/isatest-statistics
author wenzelm
Wed, 20 Sep 2006 21:02:56 +0200
changeset 20650 8188d7605c5b
parent 20646 02729d4d6e4a
child 20651 41a63aabea83
permissions -rwxr-xr-x
set terminal png color -- works for older versions of gnuplot;
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 
02729d4d6e4a make it work on sunbroy2
isatest
parents: 20615
diff changeset
    15
	;;
02729d4d6e4a make it work on sunbroy2
isatest
parents: 20615
diff changeset
    16
	*)	
02729d4d6e4a make it work on sunbroy2
isatest
parents: 20615
diff changeset
    17
		ZGREP=zgrep
02729d4d6e4a make it work on sunbroy2
isatest
parents: 20615
diff changeset
    18
	;;
02729d4d6e4a make it work on sunbroy2
isatest
parents: 20615
diff changeset
    19
esac
20611
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    20
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    21
## diagnostics
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    22
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    23
PRG="$(basename "$0")"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    24
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    25
function usage()
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    26
{
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    27
  echo
20614
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    28
  echo "Usage: $PRG DIR PLATFORM TIMESPAN SESSIONS..."
20611
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    29
  echo
20614
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    30
  echo "  Produce statistics from isatest session logs, looking TIMESPAN"
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    31
  echo "  days into the past.  Outputs .png files into DIR."
20611
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    32
  echo
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    33
  exit 1
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    34
}
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    35
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    36
function fail()
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    37
{
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    38
  echo "$1" >&2
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    39
  exit 2
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    40
}
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    41
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    42
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    43
## arguments
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    44
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    45
[ "$1" = "-?" ] && usage
20614
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    46
[ "$#" -lt "4" ] && usage
20611
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    47
20614
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    48
DIR="$1"; shift
20611
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    49
PLATFORM="$1"; shift
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    50
TIMESPAN="$1"; shift
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    51
SESSIONS="$@"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    52
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    53
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    54
## main
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    55
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    56
ALL_DATA="/tmp/isatest-all$$.dat"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    57
SESSION_DATA="/tmp/isatest$$.dat"
20614
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    58
mkdir -p "$DIR" || fail "Bad directory: $DIR"
20611
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    59
20646
02729d4d6e4a make it work on sunbroy2
isatest
parents: 20615
diff changeset
    60
$ZGREP "^Finished .*elapsed" \
20614
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    61
  $(find "$ISATEST_LOG" -name "isatest-makeall-${PLATFORM}*" -ctime "-${TIMESPAN}") | \
20611
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    62
perl -e '
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    63
  while (<>) {
20615
wenzelm
parents: 20614
diff changeset
    64
    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
    65
        my $year = $1;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    66
        my $month = $2;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    67
        my $day = $3;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    68
        my $name = $4;
20614
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    69
        my $time = ($5 * 3600 + $6 * 60 + $7) / 60;
20611
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    70
20614
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    71
        printf "$name $year-$month-$day %.2f\n", $time;
20611
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    72
    }
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    73
  }' > "$ALL_DATA"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    74
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    75
for SESSION in $SESSIONS
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    76
do
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    77
  fgrep "$SESSION " "$ALL_DATA" > "$SESSION_DATA"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    78
  gnuplot <<EOF
20650
8188d7605c5b set terminal png color -- works for older versions of gnuplot;
wenzelm
parents: 20646
diff changeset
    79
set terminal png color
20614
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    80
set output "$DIR/${SESSION}.png"
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    81
set xdata time
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    82
set timefmt "%Y-%m-%d"
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    83
set format x "%d-%b"
948ad402c8a7 target dir;
wenzelm
parents: 20612
diff changeset
    84
set xlabel "$SESSION"
20646
02729d4d6e4a make it work on sunbroy2
isatest
parents: 20615
diff changeset
    85
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
    86
EOF
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    87
done
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    88
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    89
rm -f "$ALL_DATA" "$SESSION_DATA"