+ $argc = count($argv);
+
+ logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." ".$queue["parameter"]);
+
+ $stamp = (float)microtime(true);
+
+ // We use the callstack here to analyze the performance of executed worker entries.
+ // For this reason the variables have to be initialized.
+ if (Config::get("system", "profiler")) {
+ $a->performance["start"] = microtime(true);
+ $a->performance["database"] = 0;
+ $a->performance["database_write"] = 0;
+ $a->performance["network"] = 0;
+ $a->performance["file"] = 0;
+ $a->performance["rendering"] = 0;
+ $a->performance["parser"] = 0;
+ $a->performance["marktime"] = 0;
+ $a->performance["markstart"] = microtime(true);
+ $a->callstack = array();
+ }
+
+ // For better logging create a new process id for every worker call
+ // But preserve the old one for the worker
+ $old_process_id = $a->process_id;
+ $a->process_id = uniqid("wrk", true);
+
+ $funcname($argv, $argc);
+
+ $a->process_id = $old_process_id;
+
+ $duration = number_format(microtime(true) - $stamp, 3);
+
+ logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - done in ".$duration." seconds.");
+
+ // Write down the performance values into the log
+ if (Config::get("system", "profiler")) {
+ $duration = microtime(true)-$a->performance["start"];
+
+ if (Config::get("rendertime", "callstack")) {
+ if (isset($a->callstack["database"])) {
+ $o = "\nDatabase Read:\n";
+ foreach ($a->callstack["database"] AS $func => $time) {
+ $time = round($time, 3);
+ if ($time > 0)
+ $o .= $func.": ".$time."\n";
+ }
+ }
+ if (isset($a->callstack["database_write"])) {
+ $o .= "\nDatabase Write:\n";
+ foreach ($a->callstack["database_write"] AS $func => $time) {
+ $time = round($time, 3);
+ if ($time > 0)
+ $o .= $func.": ".$time."\n";
+ }
+ }
+ if (isset($a->callstack["network"])) {
+ $o .= "\nNetwork:\n";
+ foreach ($a->callstack["network"] AS $func => $time) {
+ $time = round($time, 3);
+ if ($time > 0)
+ $o .= $func.": ".$time."\n";
+ }
+ }
+ } else {
+ $o = '';
+ }
+
+ logger("ID ".$queue["id"].": ".$funcname.": ".sprintf("DB: %s/%s, Net: %s, I/O: %s, Other: %s, Total: %s".$o,
+ number_format($a->performance["database"] - $a->performance["database_write"], 2),
+ number_format($a->performance["database_write"], 2),
+ number_format($a->performance["network"], 2),
+ number_format($a->performance["file"], 2),
+ number_format($duration - ($a->performance["database"] + $a->performance["network"] + $a->performance["file"]), 2),
+ number_format($duration, 2)),
+ LOGGER_DEBUG);