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