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