performance measurement class
More...
performance measurement class
Author: Alex Killing Alex..nosp@m.Kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
- Version
- $Id$
Definition at line 12 of file class.ilBenchmark.php.
◆ clearData()
ilBenchmark::clearData |
( |
| ) |
|
delete all measurement data
Definition at line 33 of file class.ilBenchmark.php.
References $ilDB.
37 $q =
"DELETE FROM benchmark";
38 $ilDB->manipulate($q);
◆ enable()
ilBenchmark::enable |
( |
|
$a_enable | ) |
|
enable benchmarking
Definition at line 216 of file class.ilBenchmark.php.
222 $ilias->setSetting(
"enable_bench", 1);
226 $ilias->setSetting(
"enable_bench", 0);
◆ enableDbBench()
ilBenchmark::enableDbBench |
( |
|
$a_enable, |
|
|
|
$a_user = 0 |
|
) |
| |
Enable DB benchmarking.
- Parameters
-
boolean | enable db benchmarking |
string | user account name that should be benchmarked |
Definition at line 300 of file class.ilBenchmark.php.
Referenced by save().
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);
◆ getCurrentRecordNumber()
ilBenchmark::getCurrentRecordNumber |
( |
| ) |
|
get current number of benchmark records
Definition at line 163 of file class.ilBenchmark.php.
References $ilDB.
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"];
◆ getDbBenchRecords()
ilBenchmark::getDbBenchRecords |
( |
| ) |
|
Get db benchmark records.
- Parameters
-
Definition at line 368 of file class.ilBenchmark.php.
References $ilDB, and array.
372 $set = $ilDB->query(
"SELECT * FROM benchmark");
374 while ($rec = $ilDB->fetchAssoc($set))
376 $b[] =
array(
"sql" => $rec[
"sql_stmt"],
377 "time" => $rec[
"duration"]);
Create styles array
The data for the language used.
◆ getEvaluation()
ilBenchmark::getEvaluation |
( |
|
$a_module | ) |
|
get performance evaluation data
Definition at line 138 of file class.ilBenchmark.php.
References $ilDB, and array.
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"]);
Create styles array
The data for the language used.
◆ getMaximumRecords()
ilBenchmark::getMaximumRecords |
( |
| ) |
|
get maximum number of benchmark records
Definition at line 178 of file class.ilBenchmark.php.
182 return $ilias->getSetting(
"bench_max_records");
◆ getMeasuredModules()
ilBenchmark::getMeasuredModules |
( |
| ) |
|
get all current measured modules
Definition at line 234 of file class.ilBenchmark.php.
References $ilDB, and array.
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"];
Create styles array
The data for the language used.
◆ getMeasuredTime()
ilBenchmark::getMeasuredTime |
( |
|
$a_module, |
|
|
|
$a_bench |
|
) |
| |
Get measurement.
- Returns
- Measurement in milliseconds.
Definition at line 256 of file class.ilBenchmark.php.
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];
◆ isDbBenchEnabled()
ilBenchmark::isDbBenchEnabled |
( |
| ) |
|
Check wether benchmarking is enabled or not.
Definition at line 275 of file class.ilBenchmark.php.
References $ilSetting.
Referenced by save(), startDbBench(), and stopDbBench().
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;
◆ isEnabled()
ilBenchmark::isEnabled |
( |
| ) |
|
check wether benchmarking is enabled or not
Definition at line 200 of file class.ilBenchmark.php.
References $ilSetting.
Referenced by start(), and stop().
204 if (!is_object($ilSetting))
209 return (
boolean) $ilSetting->get(
"enable_bench");
◆ microtimeDiff()
ilBenchmark::microtimeDiff |
( |
|
$t1, |
|
|
|
$t2 |
|
) |
| |
Definition at line 19 of file class.ilBenchmark.php.
Referenced by save(), and stop().
21 $t1 = explode(
" ",$t1);
22 $t2 = explode(
" ",$t2);
23 $diff = $t2[0] - $t1[0] + $t2[1] - $t1[1];
◆ save()
save all measurements
Definition at line 78 of file class.ilBenchmark.php.
References $_GET, $_POST, $GLOBALS, $ilDB, $ilIliasIniFile, $ilUser, array, defined, enableDbBench(), isDbBenchEnabled(), microtimeDiff(), ilUtil\shortenText(), and ilLog\write().
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: ".
$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.
write($a_msg, $a_log_level=NULL)
logging
Create styles array
The data for the language used.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
enableDbBench($a_enable, $a_user=0)
Enable DB benchmarking.
◆ setMaximumRecords()
ilBenchmark::setMaximumRecords |
( |
|
$a_max | ) |
|
set maximum number of benchmark records
Definition at line 189 of file class.ilBenchmark.php.
193 $ilias->setSetting(
"bench_max_records", (
int) $a_max);
◆ start()
ilBenchmark::start |
( |
|
$a_module, |
|
|
|
$a_bench |
|
) |
| |
start measurement
- Parameters
-
string | $type | measurement type |
- Returns
- int measurement id
Definition at line 49 of file class.ilBenchmark.php.
References isEnabled().
Referenced by startDbBench(), and stopDbBench().
54 $this->bench[$a_module.
":".$a_bench][] = microtime();
isEnabled()
check wether benchmarking is enabled or not
◆ startDbBench()
ilBenchmark::startDbBench |
( |
|
$a_sql | ) |
|
start measurement
- Parameters
-
string | $type | measurement type |
- Returns
- int measurement id
Definition at line 329 of file class.ilBenchmark.php.
References $ilUser, isDbBenchEnabled(), and start().
334 $this->db_enabled_user == $ilUser->getLogin() &&
335 !$this->db_bench_stop_rec)
337 $this->
start = microtime();
isDbBenchEnabled()
Check wether benchmarking is enabled or not.
start($a_module, $a_bench)
start measurement
◆ stop()
ilBenchmark::stop |
( |
|
$a_module, |
|
|
|
$a_bench |
|
) |
| |
stop measurement
- Parameters
-
Definition at line 64 of file class.ilBenchmark.php.
References isEnabled(), and microtimeDiff().
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());
isEnabled()
check wether benchmarking is enabled or not
◆ stopDbBench()
ilBenchmark::stopDbBench |
( |
| ) |
|
stop measurement
- Parameters
-
Definition at line 348 of file class.ilBenchmark.php.
References $ilUser, array, isDbBenchEnabled(), and start().
353 $this->db_enabled_user == $ilUser->getLogin() &&
354 !$this->db_bench_stop_rec)
357 array(
"start" => $this->
start,
"stop" => microtime(),
358 "sql" => $this->sql);
isDbBenchEnabled()
Check wether benchmarking is enabled or not.
Create styles array
The data for the language used.
start($a_module, $a_bench)
start measurement
◆ $bench
ilBenchmark::$bench = array() |
The documentation for this class was generated from the following file: