51 $t1 = explode(
" ", $t1);
52 $t2 = explode(
" ", $t2);
53 $diff = $t2[0] - $t1[0] + $t2[1] - $t1[1];
66 $ilDB = $DIC->database();
68 $q =
"DELETE FROM benchmark";
69 $ilDB->manipulate($q);
81 public function start($a_module, $a_bench)
92 public function stop($a_module, $a_bench)
103 $ilDB = $DIC->database();
106 $this->db_enabled_user ==
$ilUser->getLogin()) {
107 if (is_array($this->db_bench) && is_object(
$ilDB)) {
108 $this->db_bench_stop_rec =
true;
110 $ilDB->manipulate(
"DELETE FROM benchmark");
111 foreach ($this->db_bench as $b) {
116 "sql_stmt" =>
array(
"clob", $b[
"sql"])
125 if (
defined(
"SLOW_REQUEST_TIME") && SLOW_REQUEST_TIME > 0) {
126 $t1 = explode(
" ",
$GLOBALS[
'ilGlobalStartTime']);
127 $t2 = explode(
" ", microtime());
128 $diff = $t2[0] - $t1[0] + $t2[1] - $t1[1];
129 if ($diff > SLOW_REQUEST_TIME) {
132 $diff = round($diff, 4);
134 include_once(
"./Services/Logging/classes/class.ilLog.php");
135 $slow_request_log =
new ilLog(
140 $slow_request_log->
write(
"SLOW REQUEST (" . $diff .
"), Client:" . CLIENT_ID .
", GET: " .
141 str_replace(
"\n",
" ", print_r(
$_GET,
true)) .
", POST: " .
160 $q =
"SELECT COUNT(*) AS cnt, AVG(duration) AS avg_dur, benchmark," .
161 " MIN(duration) AS min_dur, MAX(duration) AS max_dur" .
163 " WHERE module = " .
$ilDB->quote($a_module,
"text") .
" " .
164 " GROUP BY benchmark" .
165 " ORDER BY benchmark";
166 $bench_set =
$ilDB->query($q);
168 while ($bench_rec =
$ilDB->fetchAssoc($bench_set)) {
169 $eva[] =
array(
"benchmark" => $bench_rec[
"benchmark"],
170 "cnt" => $bench_rec[
"cnt"],
"duration" => $bench_rec[
"avg_dur"],
171 "min" => $bench_rec[
"min_dur"],
"max" => $bench_rec[
"max_dur"]);
183 $ilDB = $DIC->database();
185 $q =
"SELECT COUNT(*) AS cnt FROM benchmark";
186 $cnt_set =
$ilDB->query($q);
187 $cnt_rec =
$ilDB->fetchAssoc($cnt_set);
189 return $cnt_rec[
"cnt"];
213 return $ilSetting->get(
"bench_max_records", (
int) $a_max);
230 return (
boolean)
$ilSetting->get(
"enable_bench");
257 $ilDB = $DIC->database();
260 $q =
"SELECT DISTINCT module FROM benchmark";
261 $mod_set =
$ilDB->query($q);
264 while ($mod_rec =
$ilDB->fetchAssoc($mod_set)) {
265 $modules[$mod_rec[
"module"]] = $mod_rec[
"module"];
279 if (isset($this->bench[$a_module .
":" . $a_bench])) {
280 return $this->bench[$a_module .
":" . $a_bench][count($this->bench[$a_module .
":" . $a_bench]) - 1];
301 if (isset($this->db_enabled)) {
302 return $this->db_enabled;
309 $this->db_enabled =
$ilSetting->get(
"enable_db_bench");
310 $this->db_enabled_user =
$ilSetting->get(
"db_bench_user");
311 return $this->db_enabled;
358 && $this->db_enabled_user ==
$ilUser->getLogin()
360 $this->
start = microtime();
380 && $this->db_enabled_user ==
$ilUser->getLogin()
382 $this->db_bench[] =
array(
383 "start" => $this->
start,
384 "stop" => microtime(),
403 $ilDB = $DIC->database();
405 $set =
$ilDB->query(
"SELECT * FROM benchmark");
407 while ($rec =
$ilDB->fetchAssoc($set)) {
408 $b[] =
array(
"sql" => $rec[
"sql_stmt"],
409 "time" => $rec[
"duration"]);
getMeasuredModules()
get all current measured modules
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
enable($a_enable)
enable benchmarking
stop($a_module, $a_bench)
stop measurement
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
if(!array_key_exists('StateId', $_REQUEST)) $id
__construct()
Constructor.
isDbBenchEnabled()
Check wether benchmarking is enabled or not.
write($a_msg, $a_log_level=null)
logging
startDbBench($a_sql)
start measurement
getCurrentRecordNumber()
get current number of benchmark records
isEnabled()
check wether benchmarking is enabled or not
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.
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.