]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/scripts/public_html/bench.php
Preparing for 0.5.9 release.
[helm.git] / helm / software / matita / scripts / public_html / bench.php
1 <?php require("common.php"); 
2   
3 // syntax
4 //
5 // queries ::= query | query "###" queries
6 // query ::= name "@@@" sql
7 //
8 $limits = array("20","50","100");
9
10 $query_last_mark = "select mark from bench order by mark desc limit 1;";
11 $last_mark = "";
12 function set_last_mark($a) {
13  global $last_mark;
14  foreach ($a as $k => $v) {
15    $last_mark = $v;
16  }
17 }
18 query($query_last_mark,"set_last_mark");
19
20 $query_last_svn_mark = "select revision from bench_svn where mark='$last_mark';";
21 $last_svn_mark = "";
22 function set_last_svn_mark($a) {
23  global $last_svn_mark;
24  foreach ($a as $k => $v) {
25    $last_svn_mark = trim($v);
26  }
27 }
28 query($query_last_svn_mark,"set_last_svn_mark");
29
30 $query_before_last_mark = "select mark from bench where mark <> '$last_mark' order by mark desc limit 1;";
31 $before_last_mark = "";
32 function set_before_last_mark($a) {
33  global $before_last_mark;
34  foreach ($a as $k => $v) {
35    $before_last_mark = $v;
36  }
37 }
38 query($query_before_last_mark,"set_before_last_mark");
39
40 $query_before_last_svn_mark = "select revision from bench_svn where mark='$before_last_mark';";
41 $before_last_svn_mark = "";
42 function set_before_last_svn_mark($a) {
43  global $before_last_svn_mark;
44  foreach ($a as $k => $v) {
45    $before_last_svn_mark = trim($v);
46  }
47 }
48 query($query_before_last_svn_mark,"set_before_last_svn_mark");
49
50   
51 $quey_all = urlencode("
52 Whole content:
53 @@@
54 select * from bench order by mark desc***");
55
56 $query_time_diff = urlencode("
57 Time diff:
58 @@@
59 select 
60   b1.test as test, b1.timeuser as oldtime, b2.timeuser as newtime, b1.compilation as comp, b1.options as opts,
61   (b2.timeuser - b1.timeuser) as diff
62 from 
63   bench as b1, bench as b2 
64 where 
65   b1.test = b2.test and 
66   b1.options = b2.options and
67   b1.compilation = b2.compilation and 
68   b1.result = b2.result and 
69   b1.mark = '$before_last_mark' and b2.mark= '$last_mark' and
70   ABS(b2.timeuser - b1.timeuser) > 100
71 order by diff desc***");
72
73 $query_result_diff = urlencode("
74 Result diff:
75 @@@
76 select 
77   b1.test as test, b1.result as oldresult, b2.result as newresult, b1.timeuser as oldtime, b2.timeuser as newtime, b1.compilation as comp, b1.options as opts,
78   (b2.timeuser - b1.timeuser) as diff
79 from 
80   bench as b1, bench as b2 
81 where 
82   b1.test = b2.test and 
83   b1.options = b2.options and
84   b1.compilation = b2.compilation and 
85   b1.result <> b2.result and 
86   b1.mark = '$before_last_mark' and b2.mark= '$last_mark'
87 order by test desc***");
88
89 $query_fail = urlencode("
90 Number of failures
91 @@@
92 select 
93   mark, count(distinct test) as fail_no 
94 from bench 
95 where result = 'fail' group by mark order by mark desc***
96 ###
97 Tests failed
98 @@@
99 select distinct mark, test, result 
100 from bench 
101 where result = 'fail' order by mark desc***");
102
103 $query_gc = urlencode("
104 GC usage 
105 @@@
106 select 
107   bench.mark, SUM(bench.time) - SUM(bench1.time) as gc_hoverhead 
108 from bench, bench as bench1 
109 where 
110   bench.mark = bench1.mark and 
111   bench.test = bench1.test and 
112   bench.options = 'gc-on' and
113   bench1.options = 'gc-off' and 
114   bench.compilation = bench1.compilation 
115 group by mark***
116 ###
117 GC usage (opt)
118 @@@
119 select 
120   bench.mark, SUM(bench.time) - SUM(bench1.time) as gc_hoverhead 
121 from bench, bench as bench1
122 where 
123   bench.mark = bench1.mark and 
124   bench.test = bench1.test and 
125   bench.options = 'gc-on' and 
126   bench1.options = 'gc-off' and 
127   bench.compilation = bench1.compilation and 
128   bench.compilation = 'opt' 
129 group by mark***");
130
131 $query_auto = urlencode("
132 Auto (with GC)
133 @@@
134 select 
135   mark, SUM(bench.time) as time 
136 from 
137   bench 
138 where 
139   test='auto.ma' and options = 'gc-on' 
140 group by mark 
141 order by mark desc***
142 ### 
143 Auto (without GC)
144 @@@
145 select 
146   mark, SUM(bench.time) as time 
147 from 
148   bench 
149 where 
150   test='auto.ma' and options = 'gc-off' 
151 group by mark 
152 order by mark desc
153 ***
154 ### 
155 GC overhead
156 @@@
157 select 
158   bench.mark, SUM(bench.time) - SUM(bench1.time) as gc_hoverhead 
159 from 
160   bench, bench as bench1 
161 where 
162   bench.mark = bench1.mark and 
163   bench.test = bench1.test and 
164   bench.options = 'gc-on' and 
165   bench1.options = 'gc-off' and 
166   bench.compilation = bench1.compilation and 
167   bench.test = 'auto.ma' 
168 group by mark
169 ***");
170
171 $query_csc = urlencode("
172 Performances per mark
173 @@@
174 select 
175   bench_times_opt.mark as mark,
176   bench_svn.revision,
177   bench_times_opt.time     as time_opt,
178   bench_times_opt.timeuser as timeuser_opt,
179   bench_times_opt.tests as tests_opt,
180   bench_fails_opt.count as fail_opt
181 from 
182   bench_svn, 
183   (select 
184     b1.mark as mark, SUM(b1.time) as time, 
185     SUM(b1.timeuser) as timeuser,COUNT(DISTINCT b1.test) as tests
186    from bench as b1
187    where 
188      b1.options = 'gc-on' and 
189      b1.compilation = 'opt' 
190      group by b1.mark) as bench_times_opt,
191   (select
192     b1.mark as mark,
193     SUM(if(b1.result='fail' and b1.compilation='opt' and b1.options='gc-on',1,0))
194     as count
195    from bench as b1
196    group by b1.mark) as bench_fails_opt
197 where 
198   bench_times_opt.mark = bench_fails_opt.mark and 
199   bench_svn.mark = bench_times_opt.mark 
200   order by bench_svn.mark desc
201 ***");
202
203 $query_total = urlencode("
204 Max N
205 @@@
206 select 
207   COUNT(DISTINCT test) as MAX 
208 from 
209   bench 
210 group by mark 
211 order by MAX desc 
212 LIMIT 0,1;
213 ###
214 Number of compiled tests
215 @@@
216 select 
217   mark, 
218   COUNT(DISTINCT test) as N 
219 from 
220   bench 
221 group by mark 
222 order by mark desc
223 ***");
224
225 function minus1_to_all($s){
226   if ($s == "-1") 
227     return "all";
228   else 
229     return $s;
230 }
231
232 function links_of($name,$q,$limits){
233   echo "<li>$name :&nbsp;&nbsp;&nbsp;";
234   if (strpos($q, urlencode("***")) === false) {
235     echo "<a href=\"showquery.php?query=$q;\">all</a>";
236   } else {
237     foreach($limits as $l) {
238       $q1 = str_replace(urlencode("***"), " LIMIT 0,$l", $q);
239       echo "<a href=\"showquery.php?query=$q1;\">" . 
240             minus1_to_all($l) . "</a>&nbsp;&nbsp;";
241     }
242       $q1 = str_replace(urlencode("***"), " ", $q);
243       echo "<a href=\"showquery.php?query=$q1;\">" . 
244             minus1_to_all("-1") . "</a>&nbsp;&nbsp;";
245   }
246   echo "</li>";
247 }
248
249 function last_commits() {
250  global $last_svn_mark;
251  global $before_last_svn_mark;
252  $query = "svn log -r$last_svn_mark:$before_last_svn_mark -v svn://mowgli.cs.unibo.it/trunk/helm/software";
253  echo $query;
254  exec($query,$res);
255  echo "<pre>";
256  foreach ($res as $k => $v) { echo "$v\n"; }
257  echo "</pre>";
258 }
259
260 ?>
261
262 <html>
263   <head>
264   <link type="text/css" rel="stylesheet" href="style.css"/>
265   </head>
266   <body>
267     <h1>QUERY the benchmark system</h1>
268     <h2>Last Commits</h2>
269     <? last_commits() ?>
270     <h2>Common Queries</h2>
271     <p>
272       <ul>
273       <? links_of("Broken tests",$query_fail,$limits) ?>
274       <? links_of("Time diff",$query_time_diff,$limits) ?>
275       <? links_of("Result diff",$query_result_diff,$limits) ?>
276       <? links_of("Garbage collector killer",$query_gc,$limits) ?>
277       <? links_of("Auto performances",$query_auto,$limits) ?>
278       <? links_of("Global performances",$query_csc,$limits) ?>
279       <? links_of("Number of compiled tests",$query_total,$limits) ?>
280       <? links_of("All table contents",$quey_all,$limits) ?>
281       </ul>
282     </p>
283     <h2>Custom Query - Simple Interface</h2>
284     <form action="composequery.php" method="get">
285     <table>
286   <tr>
287     <td>Marks:</td>
288     <td> 
289       <select name="mark">";
290         <option value="--">--</option>";
291         <?query("select distinct mark from bench order by mark desc;",
292             "array_to_combo");?>
293       </select>      
294     </td>
295   </tr>
296   <tr>
297     <td>Compilations:</td>
298     <td> 
299       <select name="compilation">";
300         <option value="--">--</option>";
301           <?query("select distinct compilation from bench;","array_to_combo");?>
302       </select>      
303     </td>
304   </tr>
305   <tr>
306     <td>Options:</td>
307     <td>  
308       <select name="options">";
309         <option value="--">--</option>";
310           <?query("select distinct options from bench;","array_to_combo");?>
311       </select>      
312     </td>
313   </tr>
314   <tr>
315     <td>Tests:</td>
316     <td>    
317       <select name="test">";
318         <option value="--">--</option>";
319           <?query("select distinct test from bench order by test;","array_to_combo");?>
320       </select>      
321     </td>
322   </tr>
323   <tr>
324     <td>Test results:</td>
325     <td>
326       <select name="result">";
327         <option value="--">--</option>";
328           <?query("select distinct result from bench;","array_to_combo"); ?>
329       </select>      
330     </td>
331   </tr>
332   <tr>
333     <td>Group By: </td>
334     <td>
335       <select name="groupby">";
336         <option value="--">--</option>";
337         <? array_to_combo(array("mark"));array_to_combo(array("options")); ?>
338       </select>      
339     </td>
340   </tr>
341   <tr>
342     <td>Limit: </td>
343     <td>
344       <select name="limit">";
345         <option value="--">--</option>";
346       <? foreach(array($limits) as $l) {array_to_combo($l);} ?>
347       </select>      
348     </td>
349   </tr>
350   <tr>
351     <td><input type="submit" value="Submit" class="button" /></td>
352   </tr>
353  </table>
354 </form>
355 <h2>Custom Query - raw SQL</h2>
356 <form action="showquery.php" method="get">
357 <table>
358 <tr><td>'bench' table description:</td></tr>
359 </tr>
360 <? query("describe bench","printer"); $i=0; ?>
361 </tr>
362 <tr><td></td></tr>
363 <tr><td></td></tr>
364 <tr><td>'bench_svn' table description:</td></tr>
365 </tr>
366 <? query("describe bench_svn","printer"); $i=0; ?>
367 </tr>
368 <tr><td></td></tr>
369 <tr><td colspan="7">
370 SQL (only one query, ';' if present must terminate the query, no characters allowed after it):</td></tr>
371 <tr><td colspan="7">
372 <textarea rows="10" cols="120" name="query"/>
373 select 
374   b1.test as test, b1.timeuser as oldtime, b2.timeuser as newtime, b1.compilation as comp, b1.options as opts,
375   (b2.timeuser - b1.timeuser) as diff
376 from 
377   bench as b1, bench as b2 
378 where 
379   b1.test = b2.test and 
380   b1.options = b2.options and
381   b1.compilation = b2.compilation and 
382   b1.result = b2.result and 
383   b1.mark = '<?php echo $before_last_mark ?>' and b2.mark= '<?php echo $last_mark ?>' and
384   ABS(b2.timeuser - b1.timeuser) &gt; 100
385 order by diff desc;
386 </textarea>
387 </td>
388 </tr>
389 <tr><td>
390 <input type="submit" value="Submit" class="button" /></td>
391 </tr>
392 </table>
393 </form>
394
395 </body>
396 </html>