]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/scripts/crontab.sh
new snapshot
[helm.git] / matita / scripts / crontab.sh
index 65578a87c3989c708dd939e8285bff9b5e38a70a..06cb81654aaa69600992ee60a636ee291be370be 100644 (file)
@@ -1,4 +1,7 @@
 #!/bin/bash
+#set -x
+
+#configuration
 TODAY=`date +%Y%m%d`
 YESTERDAY=`date -d yesterday +%Y%m%d`
 TMPDIRNAME=$HOME/__${TODAY}_crontab
@@ -7,18 +10,26 @@ SVNROOT="svn+ssh://mowgli.cs.unibo.it/local/svn/helm/trunk/"
 SHELLTIME2CENTSPHP=scripts/shell_time2cents.php
 SHELLADDERPHP=scripts/shell_adder.php
 COMMONPHP=scripts/public_html/common.php
-
-
+MYSQL="mysql -u helm -h mowgli.cs.unibo.it matita"
+SQLQMARK="select distinct mark from bench where mark like '%s%%' order by mark;"
+SQLQTIME="select SUM(timeuser) from bench where mark = '%s' group by mark;"
+SQLQFAILCOUNT="select count(distinct test) from bench where mark = '%s' and result = 'fail';"
+SQLQFAIL="select distinct test from bench where mark = '%s' and result = 'fail';"
+URL="http://mowgli.cs.unibo.it/~sacerdot/bench.php"
+
+#initialization
 OLD=$PWD
 mkdir -p $TMPDIRNAME
 rm -rf $TMPDIRNAMEOLD
 cd $TMPDIRNAME
 rm -rf helm
 svn co ${SVNROOT}helm/software/matita/scripts/ > LOG.svn 2>&1
+
+#run tests
 scripts/profile_svn.sh 2> LOG
 
-MARK=`echo "select distinct mark from bench where mark like '$TODAY%' order by mark" | mysql -u helm matita | tail -n 1`
-LASTMARK=`echo "select distinct mark from bench where mark like '$YESTERDAY%' order by mark" | mysql -u helm matita | tail -n 1`
+MARK=`printf "$SQLQMARK" "$TODAY" | $MYSQL | tail -n 1`
+LASTMARK=`printf "$SQLQMARK" "$YESTERDAY" | $MYSQL | tail -n 1`
 
 if [ -z "$MARK" ]; then
   echo "No benchmark records for $TODAY"
@@ -30,47 +41,75 @@ if [ -z "$LASTMARK" ]; then
   exit 1
 fi
 
-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;"`
-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;"`
+#check for slowdown
+CUR_TIME=`printf "$SQLQTIME" "$MARK" | $MYSQL | tail -n 1`
+OLD_TIME=`printf "$SQLQTIME" "$LASTMARK" | $MYSQL | tail -n 1`
+
+if [ -z "$CUR_TIME" -o -z "$OLD_TIME" ]; then
+    cat <<EOT
 
-CUR_CENTS=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLTIME2CENTSPHP -- $COMMONPHP $CUR_TIME`
-OLD_CENTS=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLTIME2CENTSPHP -- $COMMONPHP $OLD_TIME`
+    Unable to calculate total time amounts:
+    
+      `printf "$SQLQTIME" "$MARK"`
+      
+    or
 
-((DELTA=$CUR_CENTS-$OLD_CENTS))
-if [ $DELTA -lt 0 ]; then
+      `printf "$SQLQTIME" "$LASTMARK"`
+      
+    gave an empty result
+    
+EOT
+fi
+
+((DELTA= $CUR_TIME - $OLD_TIME))
+if [ "$DELTA" -lt 0 ]; then
   PERC=0
 else
-  ((PERC=100 * $DELTA))
-  ((PERC=$PERC / $OLD_CENTS))
+  PERC=`lua5.1 scripts/functions.lua proportion $DELTA x $OLD_TIME 100`
 fi
-if [ $PERC -ge 5 ]; then
+if [ "$PERC" -ge 5 ]; then
   cat <<EOT
-  REPORT FOR `date`
-  http://mowgli.cs.unibo.it/~tassi/bench.php
-
-  PERFORMANCE LOSS DETECTED (MARK $MARK vs MARK $LASTMARK)
-  is $CUR_TIME sec 
-  was $OLD_TIME sec
-
+  
+  Performance loss detected (MARK $MARK vs MARK $LASTMARK)
+  
+  Is: `lua5.1 scripts/functions.lua t2s $CUR_TIME` 
+  Was: `lua5.1 scripts/functions.lua t2s $OLD_TIME`
+  
+  For details: $URL
 EOT
 fi
 
-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';"`
-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';"`
+#check for more broken tests
+CUR_FAIL=`printf "$SQLQFAILCOUNT" "$MARK" | $MYSQL | tail -n 1`
+OLD_FAIL=`printf "$SQLQFAILCOUNT" "$LASTMARK" | $MYSQL | tail -n 1`
+
+if [ "$CUR_FAIL" -gt "$OLD_FAIL" ]; then
+  TMP1=`mktemp`
+  TMP2=`mktemp`
+  TMP3=`mktemp`
+  printf "$SQLQFAIL" "$MARK" | $MYSQL > $TMP1
+  printf "$SQLQFAIL" "$LASTMARK" | $MYSQL > $TMP2
+  combine $TMP1 not $TMP2 > $TMP3
 
-if [ $CUR_FAIL -gt $OLD_FAIL ]; then
   cat <<EOT
-  REPORT FOR `date`
-  http://mowgli.cs.unibo.it/~tassi/bench.php
-
-  MORE BROKEN TESTS DETECTED (MARK $MARK vs MARK $LASTMARK)
-  now broken:
-  `echo "select distinct test from bench where mark = \"$MARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita`
-  were broken:
-  `echo "select distinct test from bench where mark = \"$LASTMARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita`
+
+  More broken tests detected (MARK $MARK vs MARK $LASTMARK)
+  Is: $CUR_FAIL
+  Was: $OLD_FAIL 
+
+  Tests that are broken in $MARK but where not broken in $LASTMARK:
+`cat $TMP3`
+
+  List of broken tests in mark $MARK: 
+`cat $TMP1`
+
+  List of broken tests in old mark $LASTMARK:
+`cat $TMP2`
   
+  For details: $URL
 EOT
 
+  rm $TMP1 $TMP2 $TMP3
 fi
 
 cd $OLD