]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/scripts/crontab.sh
Bug fixed: the wrong mark was chosen for yesterday.
[helm.git] / helm / matita / scripts / crontab.sh
1 #!/bin/bash
2 TODAY=`date +%Y%m%d0200`
3 YESTERDAY=`date -d yesterday +%Y%m%d0200`
4 MARK=`echo "select distinct mark from bench where mark like '$TODAY%' order by mark" | mysql -u helm matita | tail -n 1`
5 LASTMARK=`echo "select distinct mark from bench where mark like '$YESTERDAY%' order by mark" | mysql -u helm matita | tail -n 1`
6 TMPDIRNAME=.__${MARK}_crontab
7 CVSROOT=":ext:$USER@marcello.cs.unibo.it:/home/faculty/PROJECTS/cvs/helm"
8 SHELLTIME2CENTSPHP=helm/matita/scripts/shell_time2cents.php
9 SHELLADDERPHP=helm/matita/scripts/shell_adder.php
10 COMMONPHP=helm/matita/scripts/public_html/common.php
11
12 OLD=$PWD
13 rm -rf $TMPDIRNAME 
14 mkdir $TMPDIRNAME
15 cd $TMPDIRNAME
16 cvs -d $CVSROOT co helm/matita/scripts 1>/dev/null 2>/dev/null
17 helm/matita/scripts/profile_cvs.sh 2> LOG
18
19 CUR_TIME=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP "select SEC_TO_TIME(SUM(TIME_TO_SEC(time))) from bench where mark = \"$MARK\" group by mark;"`
20 OLD_TIME=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP  "select SEC_TO_TIME(SUM(TIME_TO_SEC(time))) from bench where mark = \"$LASTMARK\" group by mark;"`
21
22 if [ -z "$CUR_TIME" -o -z "$OLD_TIME" ]; then
23   echo "No benchamks records for $MARK"
24   exit 1
25 fi
26
27 CUR_CENTS=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLTIME2CENTSPHP -- $COMMONPHP $CUR_TIME`
28 OLD_CENTS=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLTIME2CENTSPHP -- $COMMONPHP $OLD_TIME`
29
30 ((DELTA=$CUR_CENTS-$OLD_CENTS))
31 if [ $DELTA -lt 0 ]; then
32   PERC=0
33 else
34   ((PERC=100 * $DELTA))
35   ((PERC=$PERC / $OLD_CENTS))
36 fi
37 if [ $PERC -ge 5 ]; then
38   cat <<EOT
39   REPORT FOR `date`
40   http://mowgli.cs.unibo.it/~tassi/bench.php
41
42   PERFORMANCE LOSS DETECTED (MARK $MARK vs MARK $LASTMARK)
43   is $CUR_TIME sec 
44   was $OLD_TIME sec
45
46 EOT
47 fi
48
49 CUR_FAIL=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP "select count(distinct test) from bench where mark = \"$MARK\" and result = 'fail';"`
50 OLD_FAIL=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP "select count(distinct test) from bench where mark = \"$LASTMARK\" and result = 'fail';"`
51
52 if [ $CUR_FAIL -gt $OLD_FAIL ]; then
53   cat <<EOT
54   REPORT FOR `date`
55   http://mowgli.cs.unibo.it/~tassi/bench.php
56
57   MORE BROKEN TESTS DETECTED (MARK $MARK vs MARK $LASTMARK)
58   now broken:
59   `echo "select distinct test from bench where mark = \"$MARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita`
60   were broken:
61   `echo "select distinct test from bench where mark = \"$LASTMARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita`
62   
63 EOT
64
65 fi
66
67 cd $OLD
68 rm -rf $TMPDIRNAME
69