kolejna partia drobniejszych zmian (wciąż możliwe, że zacommitowany watermelon nie...
[watermeloncms.git] / wtrmln / modules / controllers / benchmarkmanager.php
blobf70a3c88ef44f078f7c6d339672e2c1a8dd4bfb1
1 <?php
2 /********************************************************************
4 Watermelon CMS
6 Copyright 2009 Radosław Pietruszewski
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ********************************************************************/
23 class BenchmarkManager extends Controller
25 function __construct()
27 parent::Controller();
30 function index()
32 setH1('Benchmark Manager');
34 // pobieramy listę benchmarków
36 $benchmarksResult = $this->db->query("SELECT * FROM `__benchmark`");
38 // jeśli brak benchmarków
40 if(!$benchmarksResult->exists())
42 echo 'brak benchmarków';
43 return;
46 // segregujemy wyniki dla danych benchmarków
48 while($benchmark = $benchmarksResult->to_obj())
50 $benchmarks[$benchmark->name][] = $benchmark->value;
53 // robimy listę
55 foreach($benchmarks as $key => $var)
57 echo '<br><br><h2>' . $key . ' [<a href="$/benchmarkmanager/delete/' . $key . '/">Usuń</a>]</h2>';
59 echo '<table>';
61 echo '<tr><th>Czas</th><th>Czas</th><th>Czas</th><th>Czas</th><th>Czas</th><th>Czas</th></tr>';
63 $i = 0;
65 foreach($var as $value)
67 if($i == 6)
69 $i = 0;
72 if($i == 0)
74 echo '<tr>';
77 echo '<td>' . $value . ' µs</td>';
79 $i++;
81 if($i == 6)
83 echo '</tr>';
86 $valuesCounter++;
87 $values = bcadd($values, $value);
90 echo '</table>';
92 echo '<strong>Średni wynik:</strong> ' . bcdiv($values, $valuesCounter) . ' µs';
96 function delete()
98 $this->db->query("DELETE FROM `__benchmark` WHERE `name` = '%1'", $this->url->segment(1));
99 $this->db->query("OPTIMIZE TABLE `__benchmark`");
101 echo 'done, <a href="$/benchmarkmanager">wróć</a>';