--- /dev/null
+<?php require("common.php");
+
+// syntax
+//
+// queries ::= query | query "###" queries
+// query ::= name "@@@" sql
+//
+
+$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;"
+ . "###" .
+ "Tests failed:@@@" .
+ "select distinct mark, test, result from bench where result = 'fail';"
+);
+$query_gc = urlencode(
+ "GC usage @@@" .
+ "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 group by mark;"
+ . "###" .
+ "GC usage (opt)@@@" .
+ "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.compilation = 'opt' group by mark;"
+ . "###" .
+ "GC usage (byte)@@@" .
+ "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.compilation = 'byte' group by mark;"
+
+);
+$query_auto = urlencode(
+ "Auto (with GC):@@@select mark, SEC_TO_TIME(SUM(TIME_TO_SEC(bench.time))) as time from bench where test='tests/auto.ma' and options = 'gc-on' group by mark;"
+ . "###" .
+ "Auto (without GC):@@@select mark, SEC_TO_TIME(SUM(TIME_TO_SEC(bench.time))) as time from bench where test='tests/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 = 'tests/auto.ma' group by mark;"
+);
+
+?>
+
+<html>
+ <head>
+ <link type="text/css" rel="stylesheet" href="style.css"/>
+ </head>
+ <body>
+ <h1>QUERY the benchmark system</h1>
+ <h2>Common Queries</h2>
+ <p>
+ <ul>
+ <li><a href="showquery.php?query=<? echo $query_fail; ?>">Broken tests</a></li>
+ <li><a href="showquery.php?query=<? echo $query_gc; ?>">Garbage collector killer</a></li>
+ <li><a href="showquery.php?query=<? echo $query_auto; ?>">Auto performances</a></li>
+ <li><a href="showquery.php?query=<? echo $quey_all; ?>">All table contents</a></li>
+ </ul>
+ </p>
+ <h2>Custom Query</h2>
+ <form action="composequery.php" method="get">
+ <table>
+ <tr><td>Marks:</td><td>
+ <? array_to_combo("mark",query("select distinct mark from bench;")); ?></td></tr>
+ <tr><td>Compilations:</td><td>
+ <? array_to_combo("compilation",query("select distinct compilation from bench;")); ?></td></tr>
+ <tr><td>Options:</td><td>
+ <? array_to_combo("options",query("select distinct options from bench;")); ?></td></tr>
+ <tr><td>Tests:</td><td>
+ <? array_to_combo("test",query("select distinct test from bench;")); ?></td></tr>
+ <tr><td>Test results:</td><td>
+ <? array_to_combo("result",query("select distinct result from bench;")); ?></td></tr>
+ <tr><td>Group By: </td><td>
+ <? array_to_combo("groupby",array(array("mark","options"))); ?></td></tr>
+ <tr><td><input type="submit" value="Submit"/></td></tr>
+ </table>
+ </form>
+ </body>
+</html>
--- /dev/null
+<?php
+
+function query($q) {
+ $db = mysql_pconnect("localhost","helm");
+ mysql_select_db("matita");
+ $rc = mysql_query($q,$db);
+ if(!$rc) {
+ die("Query failed: " . mysql_error());
+ }
+ $result = array();
+ while( $row = mysql_fetch_array($rc, MYSQL_ASSOC)){
+ $result[] = $row;
+ }
+ mysql_free_result($rc);
+ mysql_close($db);
+
+ return $result;
+}
+
+function array_to_combo($l,$a) {
+ echo "<select name=\"$l\">";
+ echo "<option value=\"--\">--</option>";
+ foreach ($a as $k => $v) {
+ foreach( array_keys($v) as $k1 => $i) {
+ echo "<option value=\"{$v[$i]}\">{$v[$i]}</option>";
+ }
+ }
+ echo "</select>";
+}
+
+?>
--- /dev/null
+<?php require("common.php");
+
+ $c = array("mark", "options", "test", "result", "compilation");
+
+ function clause_for($c) {
+ $fst = true;
+ $rc = "";
+ foreach($c as $fake => $x) {
+ $v = $_GET[$x];
+ if($v != "--") {
+ if($fst == false) {
+ $rc = $rc . " and ";
+ } else {
+ $rc = $rc . " ";
+ }
+ $fst = false;
+ $rc = $rc . $x . " = '" . $v . "'";
+ }
+ }
+ return $rc;
+ }
+
+ $gb = $_GET['groupby'];
+ if($gb != "--")
+ $what = "mark, SEC_TO_TIME(SUM(TIME_TO_SEC(time))) as sum_time, SEC_TO_TIME(SUM(TIME_TO_SEC(timeuser))) as sum_timeuser";
+ else
+ $what = "mark, time, timeuser, compilation, test, result, options";
+ $clause = clause_for($c);
+ if($clause != "")
+ $query = "select $what from bench where " . clause_for($c);
+ else
+ $query = "select $what from bench ";
+ if( $gb != "--"){
+ $query = $query. "group by $gb";
+ }
+ $query = $query. ";";
+
+ header("Location: showquery.php?query=".urlencode("Custom:@@@" . $query));
+ exit;
+?>
--- /dev/null
+<?php require("common.php");
+
+ $query = stripslashes($_GET['query']);
+
+ $nqs = explode('###',$query);
+
+ $qs = array();
+ foreach($nqs as $v){
+ $x = explode("@@@",$v);
+ $qs[$x[0]] = $x[1];
+ }
+
+?>
+<html>
+ <head>
+ <link type="text/css" rel="stylesheet" href="style.css"/>
+ </head>
+ <body>
+ <h1>QUERY results</h1>
+<? foreach( $qs as $name => $q) { ?>
+ <h2><? echo $name; ?></h2>
+ <p>
+ <tt><? print $q; ?></tt>
+ </p>
+ <table border=1>
+ <?
+ $q = query($q);
+ echo "<tr>";
+ foreach( $q[0] as $name => $txt) {
+ echo "<th>$name</th>";
+ }
+ echo "</tr>\n";
+ foreach ($q as $k => $v) {
+ echo "<tr>";
+ foreach( $v as $name => $txt) {
+ echo "<td>$txt</td>";
+ }
+ echo "</tr>\n";
+ }
+ ?>
+ </table>
+<? } ?>
+ <p><a href="bench.php">BACK to the query page</a></p>
+ </body>
+</html>