]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/scripts/crontab.sh
f59bcdb97220392a36f07a437d80a84243626c59
[helm.git] / helm / software / matita / scripts / crontab.sh
1 #!/bin/bash
2 #set -x
3
4 #configuration
5 TODAY=`date +%Y%m%d`
6 YESTERDAY=`date -d yesterday +%Y%m%d`
7 TMPDIRNAME=$HOME/__${TODAY}_crontab
8 TMPDIRNAMEOLD=$HOME/__${YESTERDAY}_crontab
9 SVNROOT="svn+ssh://mowgli.cs.unibo.it/local/svn/helm/trunk/"
10 SHELLTIME2CENTSPHP=scripts/shell_time2cents.php
11 SHELLADDERPHP=scripts/shell_adder.php
12 COMMONPHP=scripts/public_html/common.php
13 MYSQL="mysql -u helm -h mowgli.cs.unibo.it matita"
14 SQLQMARK="select distinct mark from bench where mark like '%s%%' order by mark;"
15 SQLQTIME="select SUM(timeuser) from bench where mark = '%s' group by mark;"
16 SQLQFAILCOUNT="select count(distinct test) from bench where mark = '%s' and result = 'fail';"
17 SQLQFAIL="select distinct test from bench where mark = '%s' and result = 'fail';"
18 URL="http://mowgli.cs.unibo.it/~tassi/bench.php"
19
20 #initialization
21 OLD=$PWD
22 mkdir -p $TMPDIRNAME
23 rm -rf $TMPDIRNAMEOLD
24 cd $TMPDIRNAME
25 rm -rf helm
26 svn co ${SVNROOT}helm/software/matita/scripts/ > LOG.svn 2>&1
27
28 #run tests
29 scripts/profile_svn.sh 2> LOG
30
31 MARK=`printf "$SQLQMARK" "$TODAY" | $MYSQL | tail -n 1`
32 LASTMARK=`printf "$SQLQMARK" "$YESTERDAY" | $MYSQL | tail -n 1`
33
34 if [ -z "$MARK" ]; then
35   echo "No benchmark records for $TODAY"
36   exit 1
37 fi
38
39 if [ -z "$LASTMARK" ]; then
40   echo "No benchmark records for $YESTERDAY"
41   exit 1
42 fi
43
44 #check for slowdown
45 CUR_TIME=`printf "$SQLQTIME" "$MARK" | $MYSQL | tail -n 1`
46 OLD_TIME=`printf "$SQLQTIME" "$LASTMARK" | $MYSQL | tail -n 1`
47
48 if [ -z "$CUR_TIME" -o -z "$OLD_TIME" ]; then
49     cat <<EOT
50
51     Unable to calculate total time amounts:
52     
53       `printf "$SQLQTIME" "$MARK"`
54       
55     or
56
57       `printf "$SQLQTIME" "$LASTMARK"`
58       
59     gave an empty result
60     
61 EOT
62 fi
63
64 ((DELTA= $CUR_TIME - $OLD_TIME))
65 if [ "$DELTA" -lt 0 ]; then
66   PERC=0
67 else
68   PREC=`lua5.1 scripts/functions.lua proportion $DELTA x $OLD_TIME 100`
69 fi
70 if [ "$PERC" -ge 5 ]; then
71   cat <<EOT
72   
73   Performance loss detected (MARK $MARK vs MARK $LASTMARK)
74   
75   Is: `lua5.1 scripts/functions.lua t2s $CUR_TIME` 
76   Was: `lua5.1 scripts/functions.lua t2s $OLD_TIME`
77   
78   For details: $URL
79 EOT
80 fi
81
82 #check for more broken tests
83 CUR_FAIL=`printf "$SQLQFAILCOUNT" "$MARK" | $MYSQL | tail -n 1`
84 OLD_FAIL=`printf "$SQLQFAILCOUNT" "$LASTMARK" | $MYSQL | tail -n 1`
85
86 if [ "$CUR_FAIL" -gt "$OLD_FAIL" ]; then
87   cat <<EOT
88
89   More broken tests detected (MARK $MARK vs MARK $LASTMARK)
90   Is: $CUR_FAIL
91   Was: $OLD_FAIL 
92   
93   Now broken:
94 `printf "$SQLQFAIL" "$MARK" | $MYSQL`
95
96   Were broken:
97 `printf "$SQLQFAIL" "$LASTMARK" | $MYSQL`
98   
99   For details: $URL
100 EOT
101
102 fi
103
104 cd $OLD
105 #rm -rf $TMPDIRNAME
106