]> matita.cs.unibo.it Git - helm.git/blob - matita/scripts/public_html/bench.php
tagged 0.5.0-rc1
[helm.git] / 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 GC usage (byte)
132 @@@
133 select 
134   bench.mark, SUM(bench.time) - SUM(bench1.time) as gc_hoverhead 
135 from bench, bench as bench1 
136 where 
137   bench.mark = bench1.mark and
138   bench.test = bench1.test and 
139   bench.options = 'gc-on' and 
140   bench1.options = 'gc-off' and 
141   bench.compilation = bench1.compilation and 
142   bench.compilation = 'byte' 
143 group by mark***");
144
145 $query_auto = urlencode("
146 Auto (with GC)
147 @@@
148 select 
149   mark, SUM(bench.time) as time 
150 from 
151   bench 
152 where 
153   test='auto.ma' and options = 'gc-on' 
154 group by mark 
155 order by mark desc***
156 ### 
157 Auto (without GC)
158 @@@
159 select 
160   mark, SUM(bench.time) as time 
161 from 
162   bench 
163 where 
164   test='auto.ma' and options = 'gc-off' 
165 group by mark 
166 order by mark desc
167 ***
168 ### 
169 GC overhead
170 @@@
171 select 
172   bench.mark, SUM(bench.time) - SUM(bench1.time) as gc_hoverhead 
173 from 
174   bench, bench as bench1 
175 where 
176   bench.mark = bench1.mark and 
177   bench.test = bench1.test and 
178   bench.options = 'gc-on' and 
179   bench1.options = 'gc-off' and 
180   bench.compilation = bench1.compilation and 
181   bench.test = 'auto.ma' 
182 group by mark
183 ***");
184
185 $query_csc = urlencode("
186 Performances (byte and GC) per mark
187 @@@
188 select 
189   bench_times.mark as mark,
190   bench_svn.revision,
191   bench_times.time         as time,
192   bench_times.timeuser     as timeuser,
193   bench_times_opt.time     as time_opt,
194   bench_times_opt.timeuser as timeuser_opt,
195   bench_times.tests     as tests,
196   bench_times_opt.tests as tests_opt,
197   bench_fails.count     as fail,
198   bench_fails_opt.count as fail_opt
199 from 
200   bench_svn, 
201   (select 
202     b1.mark as mark, SUM(b1.time) as time, 
203     SUM(b1.timeuser) as timeuser,COUNT(DISTINCT b1.test) as tests
204    from bench as b1
205    where 
206      b1.options = 'gc-on' and 
207      b1.compilation = 'opt' 
208      group by b1.mark) as bench_times_opt,
209   (select 
210     b1.mark as mark, SUM(b1.time) as time, 
211     SUM(b1.timeuser) as timeuser,COUNT(DISTINCT b1.test) as tests
212    from bench as b1
213    where 
214      b1.options = 'gc-on' and 
215      b1.compilation = 'byte' 
216      group by b1.mark) as bench_times,
217   (select
218     b1.mark as mark,
219     SUM(if(b1.result='fail' and b1.compilation='byte' and b1.options='gc-on',1,0))
220     as count
221    from bench as b1
222    group by b1.mark) as bench_fails,
223   (select
224     b1.mark as mark,
225     SUM(if(b1.result='fail' and b1.compilation='opt' and b1.options='gc-on',1,0))
226     as count
227    from bench as b1
228    group by b1.mark) as bench_fails_opt
229 where 
230   bench_times.mark = bench_fails.mark and 
231   bench_times_opt.mark = bench_fails_opt.mark and 
232   bench_times.mark = bench_times_opt.mark and 
233   bench_svn.mark = bench_times.mark 
234   order by bench_svn.mark desc
235 ***");
236
237 $query_total = urlencode("
238 Max N
239 @@@
240 select 
241   COUNT(DISTINCT test) as MAX 
242 from 
243   bench 
244 group by mark 
245 order by MAX desc 
246 LIMIT 0,1;
247 ###
248 Number of compiled tests
249 @@@
250 select 
251   mark, 
252   COUNT(DISTINCT test) as N 
253 from 
254   bench 
255 group by mark 
256 order by mark desc
257 ***");
258
259 function minus1_to_all($s){
260   if ($s == "-1") 
261     return "all";
262   else 
263     return $s;
264 }
265
266 function links_of($name,$q,$limits){
267   echo "<li>$name :&nbsp;&nbsp;&nbsp;";
268   if (strpos($q, urlencode("***")) === false) {
269     echo "<a href=\"showquery.php?query=$q;\">all</a>";
270   } else {
271     foreach($limits as $l) {
272       $q1 = str_replace(urlencode("***"), " LIMIT 0,$l", $q);
273       echo "<a href=\"showquery.php?query=$q1;\">" . 
274             minus1_to_all($l) . "</a>&nbsp;&nbsp;";
275     }
276       $q1 = str_replace(urlencode("***"), " ", $q);
277       echo "<a href=\"showquery.php?query=$q1;\">" . 
278             minus1_to_all("-1") . "</a>&nbsp;&nbsp;";
279   }
280   echo "</li>";
281 }
282
283 function last_commits() {
284  global $last_svn_mark;
285  global $before_last_svn_mark;
286  $query = "svn log -r$last_svn_mark:$before_last_svn_mark -v svn://mowgli.cs.unibo.it/trunk/helm/software";
287  echo $query;
288  exec($query,$res);
289  echo "<pre>";
290  foreach ($res as $k => $v) { echo "$v\n"; }
291  echo "</pre>";
292 }
293
294 ?>
295
296 <html>
297   <head>
298   <link type="text/css" rel="stylesheet" href="style.css"/>
299   </head>
300   <body>
301     <h1>QUERY the benchmark system</h1>
302     <h2>Last Commits</h2>
303     <? last_commits() ?>
304     <h2>Common Queries</h2>
305     <p>
306       <ul>
307       <? links_of("Broken tests",$query_fail,$limits) ?>
308       <? links_of("Time diff",$query_time_diff,$limits) ?>
309       <? links_of("Result diff",$query_result_diff,$limits) ?>
310       <? links_of("Garbage collector killer",$query_gc,$limits) ?>
311       <? links_of("Auto performances",$query_auto,$limits) ?>
312       <? links_of("Global performances",$query_csc,$limits) ?>
313       <? links_of("Number of compiled tests",$query_total,$limits) ?>
314       <? links_of("All table contents",$quey_all,$limits) ?>
315       </ul>
316     </p>
317     <h2>Custom Query - Simple Interface</h2>
318     <form action="composequery.php" method="get">
319     <table>
320   <tr>
321     <td>Marks:</td>
322     <td> 
323       <select name="mark">";
324         <option value="--">--</option>";
325         <?query("select distinct mark from bench order by mark desc;",
326             "array_to_combo");?>
327       </select>      
328     </td>
329   </tr>
330   <tr>
331     <td>Compilations:</td>
332     <td> 
333       <select name="compilation">";
334         <option value="--">--</option>";
335           <?query("select distinct compilation from bench;","array_to_combo");?>
336       </select>      
337     </td>
338   </tr>
339   <tr>
340     <td>Options:</td>
341     <td>  
342       <select name="options">";
343         <option value="--">--</option>";
344           <?query("select distinct options from bench;","array_to_combo");?>
345       </select>      
346     </td>
347   </tr>
348   <tr>
349     <td>Tests:</td>
350     <td>    
351       <select name="test">";
352         <option value="--">--</option>";
353           <?query("select distinct test from bench order by test;","array_to_combo");?>
354       </select>      
355     </td>
356   </tr>
357   <tr>
358     <td>Test results:</td>
359     <td>
360       <select name="result">";
361         <option value="--">--</option>";
362           <?query("select distinct result from bench;","array_to_combo"); ?>
363       </select>      
364     </td>
365   </tr>
366   <tr>
367     <td>Group By: </td>
368     <td>
369       <select name="groupby">";
370         <option value="--">--</option>";
371         <? array_to_combo(array("mark"));array_to_combo(array("options")); ?>
372       </select>      
373     </td>
374   </tr>
375   <tr>
376     <td>Limit: </td>
377     <td>
378       <select name="limit">";
379         <option value="--">--</option>";
380       <? foreach(array($limits) as $l) {array_to_combo($l);} ?>
381       </select>      
382     </td>
383   </tr>
384   <tr>
385     <td><input type="submit" value="Submit" class="button" /></td>
386   </tr>
387  </table>
388 </form>
389 <h2>Custom Query - raw SQL</h2>
390 <form action="showquery.php" method="get">
391 <table>
392 <tr><td>'bench' table description:</td></tr>
393 </tr>
394 <? query("describe bench","printer"); $i=0; ?>
395 </tr>
396 <tr><td></td></tr>
397 <tr><td></td></tr>
398 <tr><td>'bench_svn' table description:</td></tr>
399 </tr>
400 <? query("describe bench_svn","printer"); $i=0; ?>
401 </tr>
402 <tr><td></td></tr>
403 <tr><td colspan="7">
404 SQL (only one query, ';' if present must terminate the query, no characters allowed after it):</td></tr>
405 <tr><td colspan="7">
406 <textarea rows="10" cols="120" name="query"/>
407 select 
408   b1.test as test, b1.timeuser as oldtime, b2.timeuser as newtime, b1.compilation as comp, b1.options as opts,
409   (b2.timeuser - b1.timeuser) as diff
410 from 
411   bench as b1, bench as b2 
412 where 
413   b1.test = b2.test and 
414   b1.options = b2.options and
415   b1.compilation = b2.compilation and 
416   b1.result = b2.result and 
417   b1.mark = '<?php echo $before_last_mark ?>' and b2.mark= '<?php echo $last_mark ?>' and
418   ABS(b2.timeuser - b1.timeuser) &gt; 100
419 order by diff desc;
420 </textarea>
421 </td>
422 </tr>
423 <tr><td>
424 <input type="submit" value="Submit" class="button" /></td>
425 </tr>
426 </table>
427 </form>
428
429 </body>
430 </html>