performance measurement class More...
Public Member Functions | |
| ilBenchmark () | |
| constructor | |
| microtimeDiff ($t1, $t2) | |
| clearData () | |
| delete all measurement data | |
| start ($a_module, $a_bench) | |
| start measurement | |
| stop ($a_module, $a_bench) | |
| stop measurement | |
| save () | |
| save all measurements | |
| getEvaluation ($a_module) | |
| get performance evaluation data | |
| getCurrentRecordNumber () | |
| get current number of benchmark records | |
| getMaximumRecords () | |
| get maximum number of benchmark records | |
| setMaximumRecords ($a_max) | |
| set maximum number of benchmark records | |
| isEnabled () | |
| check wether benchmarking is enabled or not | |
| enable ($a_enable) | |
| enable benchmarking | |
| getMeasuredModules () | |
| get all current measured modules | |
performance measurement class
Author: Alex Killing <Alex.Killing@gmx.de>
Definition at line 33 of file class.ilBenchmark.php.
| ilBenchmark::clearData | ( | ) |
| ilBenchmark::enable | ( | $ | a_enable | ) |
enable benchmarking
Definition at line 203 of file class.ilBenchmark.php.
References $ilias.
{
global $ilias;
if ($a_enable)
{
$ilias->setSetting("enable_bench", 1);
}
else
{
$ilias->setSetting("enable_bench", 0);
}
}
| ilBenchmark::getCurrentRecordNumber | ( | ) |
get current number of benchmark records
Definition at line 155 of file class.ilBenchmark.php.
References $q.
Referenced by save().
{
global $ilDB;
$q = "SELECT COUNT(*) AS cnt FROM benchmark";
$cnt_set = $ilDB->query($q);
$cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC);
return $cnt_rec["cnt"];
}
Here is the caller graph for this function:| ilBenchmark::getEvaluation | ( | $ | a_module | ) |
get performance evaluation data
Definition at line 130 of file class.ilBenchmark.php.
References $q.
{
global $ilDB;
$q = "SELECT COUNT(*) AS cnt, AVG(duration) AS avg_dur, benchmark,".
" MIN(duration) AS min_dur, MAX(duration) AS max_dur".
" FROM benchmark".
" WHERE module = ".$ilDB->quote($a_module)." ".
" GROUP BY benchmark".
" ORDER BY benchmark";
$bench_set = $ilDB->query($q);
$eva = array();
while($bench_rec = $bench_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$eva[] = array("benchmark" => $bench_rec["benchmark"],
"cnt" => $bench_rec["cnt"], "duration" => $bench_rec["avg_dur"],
"min" => $bench_rec["min_dur"], "max" => $bench_rec["max_dur"]);
}
return $eva;
}
| ilBenchmark::getMaximumRecords | ( | ) |
get maximum number of benchmark records
Definition at line 170 of file class.ilBenchmark.php.
References $ilias.
Referenced by save().
{
global $ilias;
return $ilias->getSetting("bench_max_records");
}
Here is the caller graph for this function:| ilBenchmark::getMeasuredModules | ( | ) |
get all current measured modules
Definition at line 221 of file class.ilBenchmark.php.
References $q.
| ilBenchmark::ilBenchmark | ( | ) |
| ilBenchmark::isEnabled | ( | ) |
check wether benchmarking is enabled or not
Definition at line 192 of file class.ilBenchmark.php.
References $ilias.
Referenced by save().
{
global $ilias;
return (boolean) $ilias->getSetting("enable_bench");
}
Here is the caller graph for this function:| ilBenchmark::microtimeDiff | ( | $ | t1, | |
| $ | t2 | |||
| ) |
Definition at line 47 of file class.ilBenchmark.php.
Referenced by stop().
{
$t1 = explode(" ",$t1);
$t2 = explode(" ",$t2);
$diff = $t2[0] - $t1[0] + $t2[1] - $t1[1];
return $diff;
}
Here is the caller graph for this function:| ilBenchmark::save | ( | ) |
save all measurements
Definition at line 98 of file class.ilBenchmark.php.
References $q, getCurrentRecordNumber(), getMaximumRecords(), and isEnabled().
{
global $ilDB;
if ($this->isEnabled() &&
($this->getMaximumRecords() > $this->getCurrentRecordNumber()))
{
foreach($this->bench as $key => $bench)
{
$bench_arr = explode(":", $key);
$bench_module = $bench_arr[0];
$benchmark = $bench_arr[1];
foreach($bench as $time)
{
$q = "INSERT INTO benchmark (cdate, duration, module, benchmark) VALUES ".
"(now(), ".$ilDB->quote($time).", ".$ilDB->quote($bench_module).", ".$ilDB->quote($benchmark).")";
$ilDB->query($q);
}
}
$this->bench = array();
}
}
Here is the call graph for this function:| ilBenchmark::setMaximumRecords | ( | $ | a_max | ) |
set maximum number of benchmark records
Definition at line 181 of file class.ilBenchmark.php.
References $ilias.
{
global $ilias;
$ilias->setSetting("bench_max_records", (int) $a_max);
}
| ilBenchmark::start | ( | $ | a_module, | |
| $ | a_bench | |||
| ) |
start measurement
| string | $type measurement type |
Definition at line 77 of file class.ilBenchmark.php.
{
$this->bench[$a_module.":".$a_bench][] = microtime();
}
| ilBenchmark::stop | ( | $ | a_module, | |
| $ | a_bench | |||
| ) |
stop measurement
| int | $mid measurement id |
Definition at line 88 of file class.ilBenchmark.php.
References microtimeDiff().
{
$this->bench[$a_module.":".$a_bench][count($this->bench[$a_module.":".$a_bench]) - 1]
= $this->microtimeDiff($this->bench[$a_module.":".$a_bench][count($this->bench[$a_module.":".$a_bench]) - 1], microtime());
}
Here is the call graph for this function:
1.7.1