2 /********************************************************************
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()
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';
46 // segregujemy wyniki dla danych benchmarków
48 while($benchmark = $benchmarksResult->to_obj())
50 $benchmarks[$benchmark->name
][] = $benchmark->value
;
55 foreach($benchmarks as $key => $var)
57 echo '<br><br><h2>' . $key . ' [<a href="$/benchmarkmanager/delete/' . $key . '/">Usuń</a>]</h2>';
61 echo '<tr><th>Czas</th><th>Czas</th><th>Czas</th><th>Czas</th><th>Czas</th><th>Czas</th></tr>';
65 foreach($var as $value)
77 echo '<td>' . $value . ' µs</td>';
87 $values = bcadd($values, $value);
92 echo '<strong>Średni wynik:</strong> ' . bcdiv($values, $valuesCounter) . ' µs';
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>';