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