]> matita.cs.unibo.it Git - helm.git/commitdiff
fix
authorEnrico Tassi <enrico.tassi@inria.fr>
Fri, 28 Oct 2005 16:21:36 +0000 (16:21 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Fri, 28 Oct 2005 16:21:36 +0000 (16:21 +0000)
helm/matita/scripts/public_html/bench.php
helm/matita/scripts/public_html/common.php

index 015e7c4c14e3749c2745ecf5383b05b521d8da01..95243617ce97eb68504330e956fd7bab6486b633 100644 (file)
@@ -9,10 +9,10 @@
 $quey_all = urlencode("Whole content:@@@select * from bench;");
 $query_fail = urlencode(
   "Number of failures:@@@" .
-  "select mark, count(distinct test) as fail_no from bench where result = 'fail' group by mark order by mark;"
+  "select mark, count(distinct test) as fail_no from bench where result = 'fail' group by mark order by mark desc;"
   . "###" . 
   "Tests failed:@@@" .
-  "select distinct mark, test, result from bench where result = 'fail';" 
+  "select distinct mark, test, result from bench where result = 'fail' sort by mark desc;" 
 );
 $query_gc = urlencode(
   "GC usage @@@" .
@@ -26,14 +26,14 @@ $query_gc = urlencode(
   
 );
 $query_auto = urlencode(
-  "Auto (with GC):@@@select mark, SEC_TO_TIME(SUM(TIME_TO_SEC(bench.time))) as time from bench where test='auto.ma' and options = 'gc-on' group by mark;"
+  "Auto (with GC):@@@select mark, SEC_TO_TIME(SUM(TIME_TO_SEC(bench.time))) as time from bench where test='auto.ma' and options = 'gc-on' group by mark order by mark desc;"
   . "###" . 
-  "Auto (without GC):@@@select mark, SEC_TO_TIME(SUM(TIME_TO_SEC(bench.time))) as time from bench where test='auto.ma' and options = 'gc-off' group by mark;"
-  . "###" . 
-  "GC overhead@@@select bench.mark, SEC_TO_TIME(SUM(TIME_TO_SEC(bench.time)) - SUM(TIME_TO_SEC(bench1.time))) as gc_hoverhead from bench, bench as bench1 where bench.mark = bench1.mark and bench.test = bench1.test and bench.options = 'gc-on' and bench1.options = 'gc-off' and bench.compilation = bench1.compilation and bench.test = 'auto.ma' group by mark;"
+  "Auto (without GC):@@@select mark, SEC_TO_TIME(SUM(TIME_TO_SEC(bench.time))) as time from bench where test='auto.ma' and options = 'gc-off' group by mark order by mark desc;"
+  #  . "###" . 
+  "GC overhead@@@select bench.mark, SEC_TO_TIME(SUM(TIME_TO_SEC(bench.time)) - SUM(TIME_TO_SEC(bench1.time))) as gc_hoverhead from bench, bench as bench1 where bench.mark = bench1.mark and bench.test = bench1.test and bench.options = 'gc-on' and bench1.options = 'gc-off' and bench.compilation = bench1.compilation and bench.test = 'auto.ma' group by mark;"
 );
 
-$query_csc = urlencode("Performances (byte and GC) per mark@@@select mark, SEC_TO_TIME(SUM(TIME_TO_SEC(time))) as sum_time, SEC_TO_TIME(SUM(TIME_TO_SEC(timeuser))) as sum_timeuser from bench where options = 'gc-on' and compilation = 'byte'group by mark;");
+$query_csc = urlencode("Performances (byte and GC) per mark@@@select mark, SEC_TO_TIME(SUM(TIME_TO_SEC(time))) as sum_time, SEC_TO_TIME(SUM(TIME_TO_SEC(timeuser))) as sum_timeuser from bench where options = 'gc-on' and compilation = 'byte'group by mark order by mark desc;");
 
 ?>
 
@@ -57,7 +57,7 @@ $query_csc = urlencode("Performances (byte and GC) per mark@@@select mark, SEC_T
     <form action="composequery.php" method="get">
     <table>
   <tr><td>Marks:</td><td> 
-    <? array_to_combo("mark",query("select distinct mark from bench;")); ?></td></tr>
+    <? array_to_combo("mark",query("select distinct mark from bench order by mark desc;")); ?></td></tr>
   <tr><td>Compilations:</td><td> 
     <? array_to_combo("compilation",query("select distinct compilation from bench;")); ?></td></tr>
   <tr><td>Options:</td><td>  
index 09de758b281cad9f24450066c0f94d9911a6df33..81a0565cf9faad81de5f47dc0258cf83db688cd0 100644 (file)
@@ -3,6 +3,11 @@
 function query($q) {
   $db = mysql_pconnect("localhost","helm");
   mysql_select_db("matita");
+  if (preg_match("/TIME_TO_SEC/",$q)) {
+    $group_by = true;
+    $q = preg_replace("/group by mark/","",$q);
+    $q = preg_replace("/SEC_TO_TIME\(SUM\(TIME_TO_SEC\(([^)]+)\)\)\)/","$1",$q);
+  }
   $rc = mysql_query($q,$db);
   if(!$rc) {
     die("Query failed: " . mysql_error());
@@ -13,8 +18,50 @@ function query($q) {
   }
   mysql_free_result($rc);
   mysql_close($db);
+  if ($group_by){
+    return group_array_by_mark($result);
+  } else {
+    return $result;
+  }
+}
+
+function sum_time($t1, $t2) {
+  $matches1 = array();
+  $matches2 = array();
+  $rex = "/^(\d+)m(\d{2})\.(\d{2})s$/";
+  $m1 = preg_match($rex,$t1,$matches1);
+  $m2 = preg_match($rex,$t2,$matches2);
+  if ($m1 != 0 && $m2 != 0) {
+    $t1_minutes = $matches1[1];
+    $t2_minutes = $matches2[1];
+    $t1_secs = $matches1[2];
+    $t2_secs = $matches2[2];
+    $t1_cents = $matches1[3];
+    $t2_cents = $matches2[3];
+    $time1 = ((int) $t1_cents) + ((int) $t1_secs) * 100 + ((int)$t1_minutes) * 6000 ;
+    $time2 = ((int) $t2_cents) + ((int) $t2_secs) * 100 + ((int)$t2_minutes) * 6000 ;
+    $sum = $time1 + $time2;
+    $min = $sum / 6000;
+    $sec = ($sum % 6000) / 100;
+    $cent = ($sum % 6000) % 100;
+    return sprintf("%dm%02d.%02ds",$min,$sec,$cent);
+  } else {
+    return $t1;
+  }
+}
 
-  return $result;
+function group_array_by_mark($a) {
+  $rc = array();
+  foreach ($a as $x) {
+    if ($rc[$x['mark']] == NULL) {
+      $rc[$x['mark']] = $x;
+    } else {
+      foreach ($rc[$x['mark']] as $k => $v) {
+        $rc[$x['mark']][$k] = sum_time($v, $x[$k]);
+      }
+    }
+  }
+  return array_values($rc);
 }
   
 function array_to_combo($l,$a) {