29                 $t1 = explode(
" ",$t1);
 
   30                 $t2 = explode(
" ",$t2);
 
   31                 $diff = $t2[0] - $t1[0] + $t2[1] - $t1[1];
 
   45                 $q = 
"DELETE FROM benchmark";
 
   46                 $ilDB->manipulate($q);
 
   57         function start($a_module, $a_bench)
 
   62                         $this->bench[$a_module.
":".$a_bench][] = microtime();
 
   72         function stop($a_module, $a_bench)
 
   77                         $this->bench[$a_module.
":".$a_bench][count($this->bench[$a_module.
":".$a_bench]) - 1]
 
   78                                 = $this->
microtimeDiff($this->bench[$a_module.
":".$a_bench][count($this->bench[$a_module.
":".$a_bench]) - 1], microtime());
 
   88                 global 
$ilDB, $ilUser;
 
   91                         $this->db_enabled_user == $ilUser->getLogin())
 
   93                         if (is_array($this->db_bench) && is_object($ilDB))
 
   95                                 $this->db_bench_stop_rec = 
true;
 
   97                                 $ilDB->manipulate(
"DELETE FROM benchmark");
 
   98                                 foreach ($this->db_bench as $b)
 
  100                                         $ilDB->insert(
"benchmark", array(
 
  101                                                 "duration" => array(
"float", $this->
microtimeDiff($b[
"start"], $b[
"stop"])),
 
  102                                                 "sql_stmt" => array(
"clob", $b[
"sql"])
 
  114                         foreach($this->bench as $key => 
$bench)
 
  116                                 $bench_arr = explode(
":", $key);
 
  117                                 $bench_module = $bench_arr[0];
 
  118                                 $benchmark = $bench_arr[1];
 
  121                                         $q = 
"INSERT INTO benchmark (cdate, duration, module, benchmark) VALUES ".
 
  124                                                 $ilDB->quote($time, 
"float").
", ".
 
  125                                                 $ilDB->quote($bench_module, 
"text").
", ".
 
  126                                                 $ilDB->quote($benchmark, 
"text").
")";
 
  127                                         $ilDB->manipulate($q);
 
  130                         $this->bench = array();
 
  147                 $q = 
"SELECT COUNT(*) AS cnt, AVG(duration) AS avg_dur, benchmark,".
 
  148                         " MIN(duration) AS min_dur, MAX(duration) AS max_dur".
 
  150                         " WHERE module = ".$ilDB->quote($a_module, 
"text").
" ".
 
  151                         " GROUP BY benchmark".
 
  152                         " ORDER BY benchmark";
 
  153                 $bench_set = $ilDB->query($q);
 
  155                 while($bench_rec = $ilDB->fetchAssoc($bench_set))
 
  157                         $eva[] = array(
"benchmark" => $bench_rec[
"benchmark"],
 
  158                                 "cnt" => $bench_rec[
"cnt"], 
"duration" => $bench_rec[
"avg_dur"],
 
  159                                 "min" => $bench_rec[
"min_dur"], 
"max" => $bench_rec[
"max_dur"]);
 
  172                 $q = 
"SELECT COUNT(*) AS cnt FROM benchmark";
 
  173                 $cnt_set = $ilDB->query($q);
 
  174                 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
 
  176                 return $cnt_rec[
"cnt"];
 
  187                 return $ilias->getSetting(
"bench_max_records");
 
  198                 $ilias->setSetting(
"bench_max_records", (
int) $a_max);
 
  209                 if (!is_object($ilSetting))
 
  214                 return (
boolean) $ilSetting->get(
"enable_bench");
 
  227                         $ilias->setSetting(
"enable_bench", 1);
 
  231                         $ilias->setSetting(
"enable_bench", 0);
 
  243                 $q = 
"SELECT DISTINCT module FROM benchmark";
 
  244                 $mod_set = $ilDB->query($q);
 
  247                 while ($mod_rec = $ilDB->fetchAssoc($mod_set))
 
  249                         $modules[$mod_rec[
"module"]] = $mod_rec[
"module"];
 
  263                 if (isset($this->bench[$a_module.
":".$a_bench]))
 
  265                         return $this->bench[$a_module.
":".$a_bench][count($this->bench[$a_module.
":".$a_bench]) - 1];
 
  284                 if (isset($this->db_enabled))
 
  286                         return $this->db_enabled;
 
  289                 if (!is_object($ilSetting))
 
  294                 $this->db_enabled = $ilSetting->get(
"enable_db_bench");
 
  295                 $this->db_enabled_user = $ilSetting->get(
"db_bench_user");
 
  296                 return $this->db_enabled;
 
  311                         $ilias->setSetting(
"enable_db_bench", 1);
 
  314                                 $ilias->setSetting(
"db_bench_user", $a_user);
 
  319                         $ilias->setSetting(
"enable_db_bench", 0);
 
  322                                 $ilias->setSetting(
"db_bench_user", $a_user);
 
  339                         $this->db_enabled_user == $ilUser->getLogin() &&
 
  340                         !$this->db_bench_stop_rec)
 
  342                         $this->
start = microtime();
 
  358                         $this->db_enabled_user == $ilUser->getLogin() &&
 
  359                         !$this->db_bench_stop_rec)
 
  362                                 array(
"start" => $this->
start, 
"stop" => microtime(),
 
  363                                         "sql" => $this->sql);
 
  377                 $set = $ilDB->query(
"SELECT * FROM benchmark");
 
  379                 while ($rec = $ilDB->fetchAssoc($set))
 
  381                         $b[] = array(
"sql" => $rec[
"sql_stmt"],
 
  382                                 "time" => $rec[
"duration"]);