58 $global_settings_available = $this->dic->isDependencyAvailable(
'settings');
59 if ($global_settings_available) {
60 $this->
settings = $this->dic->settings();
62 $this->db_bechmark_enabled = (bool) ($this->
retrieveSetting(self::ENABLE_DB_BENCH) ??
false);
78 if (!$this->db instanceof
ilDBInterface && $this->dic->isDependencyAvailable(
'database')) {
79 $this->db = $this->dic->database();
91 if (!$this->
user instanceof
ilObjUser && $this->dic->isDependencyAvailable(
'user')) {
92 $this->
user = $this->dic->user();
104 $partials1 = explode(
" ", $t1);
105 $partials2 = explode(
" ", $t2);
107 return (
string) ((float) $partials2[0] - (
float) $partials1[0] + (float) $partials2[1] - (
float) $partials1[1]);
128 public function start(
string $a_module,
string $a_bench): void
137 public function stop(
string $a_module,
string $a_bench): void
150 && $this->db_bechmark_user_id === $this->
user->getId()) {
151 if (is_array($this->collected_db_benchmarks)) {
152 $this->stop_db_recording =
true;
157 foreach ($this->collected_db_benchmarks as
$b) {
159 $db->
insert(
"benchmark", [
160 "id" => [
"integer",
$id],
161 "duration" => [
"float", $this->
microtimeDiff($b[
"start"], $b[
"stop"])],
162 "sql_stmt" => [
"clob", $b[
"sql"]]
179 $cnt_set = $db->
query(
"SELECT COUNT(*) AS cnt FROM benchmark");
181 return (
int) $cnt_rec[
"cnt"];
198 return $this->db_bechmark_enabled ===
true && $this->
isDBavailable();
203 if ($a_user ===
null) {
208 $this->db_bechmark_enabled =
true;
209 $this->
settings->set(self::ENABLE_DB_BENCH,
'1');
213 $this->db_bechmark_user_id =
$user_id;
219 $this->db_bechmark_enabled =
false;
220 $this->
settings->set(self::ENABLE_DB_BENCH,
'0');
221 $this->db_bechmark_user_id =
null;
222 $this->
settings->set(self::DB_BENCH_USER,
'0');
232 !$this->stop_db_recording
235 && $this->db_bechmark_user_id === $this->
user->getId()
237 $this->
start = (string) microtime();
238 $this->temporary_sql_storage = $a_sql;
245 !$this->stop_db_recording
248 && $this->db_bechmark_user_id === $this->
user->getId()
263 $set = $db->
query(
"SELECT * FROM benchmark");
267 "sql" => $rec[
"sql_stmt"],
268 "time" => $rec[
"duration"]
insert(string $table_name, array $values)
fetchAssoc(ilDBStatement $statement)
static _lookupId($a_user_str)
__construct()
Constructor.
start(string $a_module, string $a_bench)
start measurement
stop(string $a_module, string $a_bench)
stop measurement
Customizing of pimple-DIC for ILIAS.
isDbBenchEnabled()
Check wether benchmarking is enabled or not.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getCurrentRecordNumber()
get current number of benchmark records
retrieveSetting(string $keyword)
enableDbBenchmarkForUserName(?string $a_user)
nextId(string $table_name)
query(string $query)
Run a (read-only) Query on the database.
clearData()
delete all measurement data
startDbBench(string $a_sql)
start measurement
string $temporary_sql_storage
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
bool $db_bechmark_enabled
array $collected_db_benchmarks
microtimeDiff(string $t1, string $t2)
manipulate(string $query)
Run a (write) Query on the database.
save()
save all measurements