ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilBenchmark Class Reference

performance measurement class More...

+ Collaboration diagram for ilBenchmark:

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
 getMeasuredTime ($a_module, $a_bench)
 Get measurement.

Detailed Description

performance measurement class

Author: Alex Killing Alex..nosp@m.Kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Version
Id:
class.ilBenchmark.php 22008 2009-10-01 17:23:19Z akill

Definition at line 12 of file class.ilBenchmark.php.

Member Function Documentation

ilBenchmark::clearData ( )

delete all measurement data

Definition at line 40 of file class.ilBenchmark.php.

References $ilDB, and $q.

{
global $ilDB;
$q = "DELETE FROM benchmark";
$ilDB->manipulate($q);
}
ilBenchmark::enable (   $a_enable)

enable benchmarking

Definition at line 199 of file class.ilBenchmark.php.

{
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 146 of file class.ilBenchmark.php.

References $ilDB, and $q.

Referenced by save().

{
global $ilDB;
$q = "SELECT COUNT(*) AS cnt FROM benchmark";
$cnt_set = $ilDB->query($q);
$cnt_rec = $ilDB->fetchAssoc($cnt_set);
return $cnt_rec["cnt"];
}

+ Here is the caller graph for this function:

ilBenchmark::getEvaluation (   $a_module)

get performance evaluation data

Definition at line 121 of file class.ilBenchmark.php.

References $ilDB, and $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, "text")." ".
" GROUP BY benchmark".
" ORDER BY benchmark";
$bench_set = $ilDB->query($q);
$eva = array();
while($bench_rec = $ilDB->fetchAssoc($bench_set))
{
$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 161 of file class.ilBenchmark.php.

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 217 of file class.ilBenchmark.php.

References $ilDB, and $q.

{
global $ilDB;
$q = "SELECT DISTINCT module FROM benchmark";
$mod_set = $ilDB->query($q);
$modules = array();
while ($mod_rec = $ilDB->fetchAssoc($mod_set))
{
$modules[$mod_rec["module"]] = $mod_rec["module"];
}
return $modules;
}
ilBenchmark::getMeasuredTime (   $a_module,
  $a_bench 
)

Get measurement.

Returns
Measurement in milliseconds.

Definition at line 239 of file class.ilBenchmark.php.

{
return $this->bench[$a_module.":".$a_bench][count($this->bench[$a_module.":".$a_bench]) - 1];
}
ilBenchmark::ilBenchmark ( )

constructor

Definition at line 18 of file class.ilBenchmark.php.

{
}
ilBenchmark::isEnabled ( )

check wether benchmarking is enabled or not

Definition at line 183 of file class.ilBenchmark.php.

References $ilSetting.

Referenced by save(), start(), and stop().

{
global $ilSetting;
if (!is_object($ilSetting))
{
return true;
}
return (boolean) $ilSetting->get("enable_bench");
}

+ Here is the caller graph for this function:

ilBenchmark::microtimeDiff (   $t1,
  $t2 
)

Definition at line 26 of file class.ilBenchmark.php.

References $diff.

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 85 of file class.ilBenchmark.php.

References $benchmark, $ilDB, $key, $q, getCurrentRecordNumber(), getMaximumRecords(), and isEnabled().

{
global $ilDB;
return;
if ($this->isEnabled() &&
{
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 ".
"(".
$ilDB->now().", ".
$ilDB->quote($time, "float").", ".
$ilDB->quote($bench_module, "text").", ".
$ilDB->quote($benchmark, "text").")";
$ilDB->manipulate($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 172 of file class.ilBenchmark.php.

{
global $ilias;
$ilias->setSetting("bench_max_records", (int) $a_max);
}
ilBenchmark::start (   $a_module,
  $a_bench 
)

start measurement

Parameters
string$typemeasurement type
Returns
int measurement id

Definition at line 56 of file class.ilBenchmark.php.

References isEnabled().

{
return;
if ($this->isEnabled())
{
$this->bench[$a_module.":".$a_bench][] = microtime();
}
}

+ Here is the call graph for this function:

ilBenchmark::stop (   $a_module,
  $a_bench 
)

stop measurement

Parameters
int$midmeasurement id

Definition at line 71 of file class.ilBenchmark.php.

References isEnabled(), and microtimeDiff().

{
return;
if ($this->isEnabled())
{
$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:


The documentation for this class was generated from the following file: