28 $t1 = explode(
" ",$t1);
29 $t2 = explode(
" ",$t2);
30 $diff = $t2[0] - $t1[0] + $t2[1] - $t1[1];
44 $q =
"DELETE FROM benchmark";
45 $ilDB->manipulate(
$q);
56 function start($a_module, $a_bench)
61 $this->bench[$a_module.
":".$a_bench][] = microtime();
71 function stop($a_module, $a_bench)
76 $this->bench[$a_module.
":".$a_bench][count($this->bench[$a_module.
":".$a_bench]) - 1]
77 = $this->
microtimeDiff($this->bench[$a_module.
":".$a_bench][count($this->bench[$a_module.
":".$a_bench]) - 1], microtime());
92 foreach($this->bench as
$key => $bench)
94 $bench_arr = explode(
":",
$key);
95 $bench_module = $bench_arr[0];
97 foreach($bench as $time)
99 $q =
"INSERT INTO benchmark (cdate, duration, module, benchmark) VALUES ".
102 $ilDB->quote($time,
"float").
", ".
103 $ilDB->quote($bench_module,
"text").
", ".
105 $ilDB->manipulate(
$q);
108 $this->bench = array();
125 $q =
"SELECT COUNT(*) AS cnt, AVG(duration) AS avg_dur, benchmark,".
126 " MIN(duration) AS min_dur, MAX(duration) AS max_dur".
128 " WHERE module = ".$ilDB->quote($a_module,
"text").
" ".
129 " GROUP BY benchmark".
130 " ORDER BY benchmark";
131 $bench_set = $ilDB->query(
$q);
133 while($bench_rec = $ilDB->fetchAssoc($bench_set))
135 $eva[] = array(
"benchmark" => $bench_rec[
"benchmark"],
136 "cnt" => $bench_rec[
"cnt"],
"duration" => $bench_rec[
"avg_dur"],
137 "min" => $bench_rec[
"min_dur"],
"max" => $bench_rec[
"max_dur"]);
150 $q =
"SELECT COUNT(*) AS cnt FROM benchmark";
151 $cnt_set = $ilDB->query(
$q);
152 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
154 return $cnt_rec[
"cnt"];
165 return $ilias->getSetting(
"bench_max_records");
176 $ilias->setSetting(
"bench_max_records", (
int) $a_max);
187 if (!is_object($ilSetting))
192 return (
boolean) $ilSetting->get(
"enable_bench");
205 $ilias->setSetting(
"enable_bench", 1);
209 $ilias->setSetting(
"enable_bench", 0);
221 $q =
"SELECT DISTINCT module FROM benchmark";
222 $mod_set = $ilDB->query(
$q);
225 while ($mod_rec = $ilDB->fetchAssoc($mod_set))
227 $modules[$mod_rec[
"module"]] = $mod_rec[
"module"];
241 return $this->bench[$a_module.
":".$a_bench][count($this->bench[$a_module.
":".$a_bench]) - 1];