21 $t1 = explode(
" ",$t1);
22 $t2 = explode(
" ",$t2);
23 $diff = $t2[0] - $t1[0] + $t2[1] - $t1[1];
37 $q =
"DELETE FROM benchmark";
38 $ilDB->manipulate($q);
49 function start($a_module, $a_bench)
54 $this->bench[$a_module.
":".$a_bench][] = microtime();
64 function stop($a_module, $a_bench)
69 $this->bench[$a_module.
":".$a_bench][count($this->bench[$a_module.
":".$a_bench]) - 1]
70 = $this->
microtimeDiff($this->bench[$a_module.
":".$a_bench][count($this->bench[$a_module.
":".$a_bench]) - 1], microtime());
83 $this->db_enabled_user == $ilUser->getLogin())
85 if (is_array($this->db_bench) && is_object($ilDB))
87 $this->db_bench_stop_rec =
true;
89 $ilDB->manipulate(
"DELETE FROM benchmark");
90 foreach ($this->db_bench as $b)
92 $id = $ilDB->nextId(
'benchmark');
93 $ilDB->insert(
"benchmark",
array(
94 "id" =>
array(
"integer", $id),
96 "sql_stmt" =>
array(
"clob", $b[
"sql"])
105 if (
defined(
"SLOW_REQUEST_TIME") && SLOW_REQUEST_TIME > 0)
107 $t1 = explode(
" ",
$GLOBALS[
'ilGlobalStartTime']);
108 $t2 = explode(
" ", microtime());
109 $diff = $t2[0] - $t1[0] + $t2[1] - $t1[1];
110 if ($diff > SLOW_REQUEST_TIME)
114 $diff = round($diff, 4);
116 include_once(
"./Services/Logging/classes/class.ilLog.php");
117 $slow_request_log =
new ilLog(
118 $ilIliasIniFile->readVariable(
"log",
"slow_request_log_path"),
119 $ilIliasIniFile->readVariable(
"log",
"slow_request_log_file"),
121 $slow_request_log->
write(
"SLOW REQUEST (".$diff.
"), Client:".CLIENT_ID.
", GET: ".
122 str_replace(
"\n",
" ", print_r(
$_GET,
true)).
", POST: ".
142 $q =
"SELECT COUNT(*) AS cnt, AVG(duration) AS avg_dur, benchmark,".
143 " MIN(duration) AS min_dur, MAX(duration) AS max_dur".
145 " WHERE module = ".$ilDB->quote($a_module,
"text").
" ".
146 " GROUP BY benchmark".
147 " ORDER BY benchmark";
148 $bench_set = $ilDB->query($q);
150 while($bench_rec = $ilDB->fetchAssoc($bench_set))
152 $eva[] =
array(
"benchmark" => $bench_rec[
"benchmark"],
153 "cnt" => $bench_rec[
"cnt"],
"duration" => $bench_rec[
"avg_dur"],
154 "min" => $bench_rec[
"min_dur"],
"max" => $bench_rec[
"max_dur"]);
167 $q =
"SELECT COUNT(*) AS cnt FROM benchmark";
168 $cnt_set = $ilDB->query($q);
169 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
171 return $cnt_rec[
"cnt"];
182 return $ilias->getSetting(
"bench_max_records");
193 $ilias->setSetting(
"bench_max_records", (
int) $a_max);
204 if (!is_object($ilSetting))
209 return (
boolean) $ilSetting->get(
"enable_bench");
222 $ilias->setSetting(
"enable_bench", 1);
226 $ilias->setSetting(
"enable_bench", 0);
238 $q =
"SELECT DISTINCT module FROM benchmark";
239 $mod_set = $ilDB->query($q);
242 while ($mod_rec = $ilDB->fetchAssoc($mod_set))
244 $modules[$mod_rec[
"module"]] = $mod_rec[
"module"];
258 if (isset($this->bench[$a_module.
":".$a_bench]))
260 return $this->bench[$a_module.
":".$a_bench][count($this->bench[$a_module.
":".$a_bench]) - 1];
279 if (isset($this->db_enabled))
281 return $this->db_enabled;
284 if (!is_object($ilSetting))
289 $this->db_enabled = $ilSetting->get(
"enable_db_bench");
290 $this->db_enabled_user = $ilSetting->get(
"db_bench_user");
291 return $this->db_enabled;
306 $ilias->setSetting(
"enable_db_bench", 1);
309 $ilias->setSetting(
"db_bench_user", $a_user);
314 $ilias->setSetting(
"enable_db_bench", 0);
317 $ilias->setSetting(
"db_bench_user", $a_user);
334 $this->db_enabled_user == $ilUser->getLogin() &&
335 !$this->db_bench_stop_rec)
337 $this->
start = microtime();
353 $this->db_enabled_user == $ilUser->getLogin() &&
354 !$this->db_bench_stop_rec)
357 array(
"start" => $this->
start,
"stop" => microtime(),
358 "sql" => $this->sql);
372 $set = $ilDB->query(
"SELECT * FROM benchmark");
374 while ($rec = $ilDB->fetchAssoc($set))
376 $b[] =
array(
"sql" => $rec[
"sql_stmt"],
377 "time" => $rec[
"duration"]);
getMeasuredModules()
get all current measured modules
enable($a_enable)
enable benchmarking
stop($a_module, $a_bench)
stop measurement
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
isDbBenchEnabled()
Check wether benchmarking is enabled or not.
startDbBench($a_sql)
start measurement
getCurrentRecordNumber()
get current number of benchmark records
isEnabled()
check wether benchmarking is enabled or not
write($a_msg, $a_log_level=NULL)
logging
getEvaluation($a_module)
get performance evaluation data
clearData()
delete all measurement data
getMaximumRecords()
get maximum number of benchmark records
getDbBenchRecords()
Get db benchmark records.
Create styles array
The data for the language used.
stopDbBench()
stop measurement
setMaximumRecords($a_max)
set maximum number of benchmark records
performance measurement class
start($a_module, $a_bench)
start measurement
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
save()
save all measurements
getMeasuredTime($a_module, $a_bench)
Get measurement.
enableDbBench($a_enable, $a_user=0)
Enable DB benchmarking.