55 if ($this->dic ===
null) {
60 $global_settings_available = $this->dic->isDependencyAvailable(
'settings');
61 if ($global_settings_available) {
62 $this->
settings = $this->dic->settings();
64 $this->db_bechmark_enabled = (bool) ($this->
retrieveSetting(self::ENABLE_DB_BENCH) ??
false);
80 if (!$this->db instanceof
ilDBInterface && $this->dic->isDependencyAvailable(
'database')) {
81 $this->db = $this->dic->database();
93 if (!$this->
user instanceof
ilObjUser && $this->dic->isDependencyAvailable(
'user')) {
94 $this->
user = $this->dic->user();
106 $partials1 = explode(
" ", $t1);
107 $partials2 = explode(
" ", $t2);
109 return (
string) ((float) $partials2[0] - (
float) $partials1[0] + (float) $partials2[1] - (
float) $partials1[1]);
130 public function start(
string $a_module,
string $a_bench): void
139 public function stop(
string $a_module,
string $a_bench): void
152 && $this->db_bechmark_user_id === $this->
user->getId()) {
153 if (is_array($this->collected_db_benchmarks)) {
154 $this->stop_db_recording =
true;
159 foreach ($this->collected_db_benchmarks as
$b) {
162 "id" => [
"integer",
$id],
163 "duration" => [
"float", $this->
microtimeDiff($b[
"start"],
$b[
"stop"])],
164 "sql_stmt" => [
"clob",
$b[
"sql"]]
184 return $this->db_bechmark_enabled ===
true && $this->
isDBavailable();
189 if ($a_user ===
null) {
194 $this->db_bechmark_enabled =
true;
195 $this->
settings->set(self::ENABLE_DB_BENCH,
'1');
199 $this->db_bechmark_user_id =
$user_id;
205 $this->db_bechmark_enabled =
false;
206 $this->
settings->set(self::ENABLE_DB_BENCH,
'0');
207 $this->db_bechmark_user_id =
null;
208 $this->
settings->set(self::DB_BENCH_USER,
'0');
218 !$this->stop_db_recording
221 && $this->db_bechmark_user_id === $this->
user->getId()
223 $this->
start = microtime();
224 $this->temporary_sql_storage = $a_sql;
231 !$this->stop_db_recording
234 && $this->db_bechmark_user_id === $this->
user->getId()
249 $set =
$db->
query(
"SELECT * FROM benchmark");
253 "sql" => $rec[
"sql_stmt"],
254 "time" => $rec[
"duration"]
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Customizing of pimple-DIC for ILIAS.
microtimeDiff(string $t1, string $t2)
isDbBenchEnabled()
Check wether benchmarking is enabled or not.
__construct()
Constructor.
retrieveSetting(string $keyword)
start(string $a_module, string $a_bench)
start measurement
startDbBench(string $a_sql)
start measurement
string $temporary_sql_storage
enableDbBenchmarkForUserName(?string $a_user)
array $collected_db_benchmarks
save()
save all measurements
stop(string $a_module, string $a_bench)
stop measurement
clearData()
delete all measurement data
bool $db_bechmark_enabled
static _lookupId(string|array $a_user_str)
insert(string $table_name, array $values)
nextId(string $table_name)
manipulate(string $query)
Run a (write) Query on the database.
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)