Admin/isatest-statistics
author wenzelm
Tue, 19 Sep 2006 20:53:42 +0200
changeset 20611 ef4661e2e602
child 20612 706c22b3a8fb
permissions -rwxr-xr-x
Produce statistics from isatest session logs.
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
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    10
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    11
## diagnostics
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    12
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    13
PRG="$(basename "$0")"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    14
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    15
function usage()
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    16
{
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    17
  echo
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    18
  echo "Usage: $PRG PLATFORM TIMESPAN SESSIONS..."
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    19
  echo
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    20
  echo "  Produce statistics from isatest session logs,"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    21
  echo "  looking TIMESPAN days into the past."
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    22
  echo
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    23
  exit 1
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    24
}
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    25
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    26
function fail()
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    27
{
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    28
  echo "$1" >&2
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    29
  exit 2
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    30
}
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    31
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    32
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    33
## arguments
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    34
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    35
[ "$1" = "-?" ] && usage
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    36
[ "$#" -lt "3" ] && usage
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    37
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    38
PLATFORM="$1"; shift
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    39
TIMESPAN="$1"; shift
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    40
SESSIONS="$@"
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
## main
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    44
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    45
ALL_DATA="/tmp/isatest-all$$.dat"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    46
SESSION_DATA="/tmp/isatest$$.dat"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    47
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    48
zgrep "^Finished .*elapsed" \
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    49
  $(find -name "isatest-makeall-${PLATFORM}*" -ctime "-${TIMESPAN}") | \
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    50
perl -e '
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    51
  while (<>) {
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    52
    if (m/isatest-makeall-\w+-\w+-(\d+)-(\d+)-(\d+)-.*:Finished (\S+) \(.*, (\d+):(\d+):(\d+) cpu time\)/) {
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    53
        my $year = $1;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    54
        my $month = $2;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    55
        my $day = $3;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    56
        my $name = $4;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    57
        my $h = $5;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    58
        my $m = $6;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    59
        my $s = $7;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    60
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    61
        my $date = $month - 1 + ($day - 1) / 31;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    62
        my $time = ($h * 3600 + $m * 60 + $s) / 60;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    63
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    64
        printf "%s %.2f %.2f\n", $name, $date, $time;
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    65
    }
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    66
  }' > "$ALL_DATA"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    67
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    68
for SESSION in $SESSIONS
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    69
do
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    70
  fgrep "$SESSION " "$ALL_DATA" > "$SESSION_DATA"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    71
  gnuplot <<EOF
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    72
set terminal png
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    73
set output "${SESSION}.png"
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    74
plot [] [0:40] "$SESSION_DATA" using 2:3 title "$SESSION" smooth sbezier, "$SESSION_DATA" using 2:3 title "$SESSION" smooth csplines
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    75
EOF
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    76
done
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    77
ef4661e2e602 Produce statistics from isatest session logs.
wenzelm
parents:
diff changeset
    78
rm -f "$ALL_DATA" "$SESSION_DATA"