diff --git a/src/App.php b/src/App.php index 6e1f83fdd6..e61b8dbae4 100644 --- a/src/App.php +++ b/src/App.php @@ -493,7 +493,7 @@ class App unset($db_host, $db_user, $db_pass, $db_data, $charset); - $this->profiler->saveTimestamp($stamp1, 'network'); + $this->profiler->saveTimestamp($stamp1, 'network', Core\System::callstack()); } public function getScheme() @@ -1189,7 +1189,7 @@ class App if (!$this->isBackend()) { $stamp1 = microtime(true); session_start(); - $this->profiler->saveTimestamp($stamp1, 'parser'); + $this->profiler->saveTimestamp($stamp1, 'parser', Core\System::callstack()); Core\L10n::setSessionVariable(); Core\L10n::setLangFromSession(); } else { diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 75cb32b626..e9b5f98d0b 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1027,7 +1027,7 @@ class BBCode extends BaseObject @curl_exec($ch); $curl_info = @curl_getinfo($ch); - $a->getProfiler()->saveTimestamp($stamp1, "network"); + $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack()); if (substr($curl_info["content_type"], 0, 6) == "image/") { $text = "[url=" . $match[1] . "]" . $match[1] . "[/url]"; @@ -1086,7 +1086,7 @@ class BBCode extends BaseObject @curl_exec($ch); $curl_info = @curl_getinfo($ch); - $a->getProfiler()->saveTimestamp($stamp1, "network"); + $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack()); // if its a link to a picture then embed this picture if (substr($curl_info["content_type"], 0, 6) == "image/") { @@ -1915,7 +1915,7 @@ class BBCode extends BaseObject // unmask the special chars back to HTML $text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['<', '>', '&'], $text); - $a->getProfiler()->saveTimestamp($stamp1, "parser"); + $a->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack()); // Libertree has a problem with escaped hashtags. $text = str_replace(['\#'], ['#'], $text); diff --git a/src/Content/Text/Markdown.php b/src/Content/Text/Markdown.php index 28ee215b26..e3e2cd3ac9 100644 --- a/src/Content/Text/Markdown.php +++ b/src/Content/Text/Markdown.php @@ -7,6 +7,7 @@ namespace Friendica\Content\Text; use Friendica\BaseObject; +use Friendica\Core\System; use Friendica\Model\Contact; use Michelf\MarkdownExtra; @@ -36,7 +37,7 @@ class Markdown extends BaseObject $html = $MarkdownParser->transform($text); $html = preg_replace('/getProfiler()->saveTimestamp($stamp1, "parser", System::callstack()); return $html; } diff --git a/src/Core/Addon.php b/src/Core/Addon.php index 483882c3ed..7957e08350 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -219,7 +219,7 @@ class Addon extends BaseObject $stamp1 = microtime(true); $f = file_get_contents("addon/$addon/$addon.php"); - $a->getProfiler()->saveTimestamp($stamp1, "file"); + $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack()); $r = preg_match("|/\*.*\*/|msU", $f, $m); diff --git a/src/Core/Cache.php b/src/Core/Cache.php index cd1581ef93..cadb2444b5 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -63,7 +63,7 @@ class Cache extends \Friendica\BaseObject $return = self::getDriver()->getAllKeys($prefix); - self::getApp()->getProfiler()->saveTimestamp($time, 'cache'); + self::getApp()->getProfiler()->saveTimestamp($time, 'cache', System::callstack()); return $return; } @@ -82,7 +82,7 @@ class Cache extends \Friendica\BaseObject $return = self::getDriver()->get($key); - self::getApp()->getProfiler()->saveTimestamp($time, 'cache'); + self::getApp()->getProfiler()->saveTimestamp($time, 'cache', System::callstack()); return $return; } @@ -105,7 +105,7 @@ class Cache extends \Friendica\BaseObject $return = self::getDriver()->set($key, $value, $duration); - self::getApp()->getProfiler()->saveTimestamp($time, 'cache_write'); + self::getApp()->getProfiler()->saveTimestamp($time, 'cache_write', System::callstack()); return $return; } @@ -124,7 +124,7 @@ class Cache extends \Friendica\BaseObject $return = self::getDriver()->delete($key); - self::getApp()->getProfiler()->saveTimestamp($time, 'cache_write'); + self::getApp()->getProfiler()->saveTimestamp($time, 'cache_write', System::callstack()); return $return; } diff --git a/src/Core/Logger.php b/src/Core/Logger.php index 69be501a3d..0712c91b1c 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -155,7 +155,7 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$logger->emergency($message, $context); - self::getApp()->GetProfiler()->saveTimestamp($stamp1, 'file'); + self::getApp()->GetProfiler()->saveTimestamp($stamp1, 'file', System::callstack()); } /** @@ -179,7 +179,7 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$logger->alert($message, $context); - self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file'); + self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack()); } /** @@ -202,7 +202,7 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$logger->critical($message, $context); - self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file'); + self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack()); } /** @@ -225,7 +225,7 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$logger->error($message, $context); - self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file'); + self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack()); } /** @@ -249,7 +249,7 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$logger->warning($message, $context); - self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file'); + self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack()); } /** @@ -270,7 +270,7 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$logger->notice($message, $context); - self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file'); + self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack()); } /** @@ -293,7 +293,7 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$logger->info($message, $context); - self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file'); + self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack()); } /** @@ -314,7 +314,7 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$logger->debug($message, $context); - self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file'); + self::getApp()->getProfiler()->saveTimestamp($stamp1, 'file', System::callstack()); } /** @@ -334,7 +334,7 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$logger->log($level, $msg); - self::getApp()->getProfiler()->saveTimestamp($stamp1, "file"); + self::getApp()->getProfiler()->saveTimestamp($stamp1, "file", System::callstack()); } /** @@ -355,6 +355,6 @@ class Logger extends BaseObject $stamp1 = microtime(true); self::$devLogger->log($level, $msg); - self::getApp()->getProfiler()->saveTimestamp($stamp1, "file"); + self::getApp()->getProfiler()->saveTimestamp($stamp1, "file", System::callstack()); } } diff --git a/src/Core/Renderer.php b/src/Core/Renderer.php index c032448c98..8844f26881 100644 --- a/src/Core/Renderer.php +++ b/src/Core/Renderer.php @@ -74,7 +74,7 @@ class Renderer extends BaseObject exit(); } - $a->getProfiler()->saveTimestamp($stamp1, "rendering"); + $a->getProfiler()->saveTimestamp($stamp1, "rendering", System::callstack()); return $output; } @@ -101,7 +101,7 @@ class Renderer extends BaseObject exit(); } - $a->getProfiler()->saveTimestamp($stamp1, "file"); + $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack()); return $template; } diff --git a/src/Core/Theme.php b/src/Core/Theme.php index dbfc0fd908..5479f8f46f 100644 --- a/src/Core/Theme.php +++ b/src/Core/Theme.php @@ -51,7 +51,7 @@ class Theme $a = \get_app(); $stamp1 = microtime(true); $theme_file = file_get_contents("view/theme/$theme/theme.php"); - $a->getProfiler()->saveTimestamp($stamp1, "file"); + $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack()); $result = preg_match("|/\*.*\*/|msU", $theme_file, $matches); diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 7c24ecfd33..edef309015 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -587,7 +587,7 @@ class DBA self::$errorno = $errorno; } - self::$profiler->saveTimestamp($stamp1, 'database'); + self::$profiler->saveTimestamp($stamp1, 'database', System::callstack()); if (self::$configCache->get('system', 'db_log')) { $stamp2 = microtime(true); @@ -658,7 +658,7 @@ class DBA self::$errorno = $errorno; } - self::$profiler->saveTimestamp($stamp, "database_write"); + self::$profiler->saveTimestamp($stamp, "database_write", System::callstack()); return $retval; } @@ -827,7 +827,7 @@ class DBA } } - self::$profiler->saveTimestamp($stamp1, 'database'); + self::$profiler->saveTimestamp($stamp1, 'database', System::callstack()); return $columns; } @@ -1564,7 +1564,7 @@ class DBA break; } - self::$profiler->saveTimestamp($stamp1, 'database'); + self::$profiler->saveTimestamp($stamp1, 'database', System::callstack()); return $ret; } diff --git a/src/Object/Image.php b/src/Object/Image.php index c439553754..45c8bedeaf 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -656,7 +656,7 @@ class Image $stamp1 = microtime(true); file_put_contents($path, $string); - $a->getProfiler()->saveTimestamp($stamp1, "file"); + $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack()); } /** @@ -802,7 +802,7 @@ class Image $a = \get_app(); $stamp1 = microtime(true); file_put_contents($tempfile, $img_str); - $a->getProfiler()->saveTimestamp($stamp1, "file"); + $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack()); $data = getimagesize($tempfile); unlink($tempfile); @@ -910,7 +910,7 @@ class Image $stamp1 = microtime(true); $imagedata = @file_get_contents($url); - $a->getProfiler()->saveTimestamp($stamp1, "file"); + $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack()); } $maximagesize = Config::get('system', 'maximagesize'); @@ -924,7 +924,7 @@ class Image $stamp1 = microtime(true); file_put_contents($tempfile, $imagedata); - $a->getProfiler()->saveTimestamp($stamp1, "file"); + $a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack()); $data = getimagesize($tempfile); diff --git a/src/Util/Network.php b/src/Util/Network.php index 4d5afa3a36..cda8c9a71d 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -232,7 +232,7 @@ class Network @curl_close($ch); - $a->getProfiler()->saveTimestamp($stamp1, 'network'); + $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack()); return $curlResponse; } @@ -334,7 +334,7 @@ class Network curl_close($ch); - $a->getProfiler()->saveTimestamp($stamp1, 'network'); + $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack()); Logger::log('post_url: end ' . $url, Logger::DATA); @@ -641,7 +641,7 @@ class Network $http_code = $curl_info['http_code']; curl_close($ch); - $a->getProfiler()->saveTimestamp($stamp1, "network"); + $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack()); if ($http_code == 0) { return $url; @@ -683,7 +683,7 @@ class Network $body = curl_exec($ch); curl_close($ch); - $a->getProfiler()->saveTimestamp($stamp1, "network"); + $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack()); if (trim($body) == "") { return $url; diff --git a/src/Util/Profiler.php b/src/Util/Profiler.php index 7bf30a2775..f65bede152 100644 --- a/src/Util/Profiler.php +++ b/src/Util/Profiler.php @@ -2,7 +2,6 @@ namespace Friendica\Util; -use Friendica\Core; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; @@ -58,8 +57,9 @@ class Profiler implements ContainerInterface * * @param int $timestamp the Timestamp * @param string $value A value to profile + * @param string $callstack The callstack of the current profiling data */ - public function saveTimestamp($timestamp, $value) + public function saveTimestamp($timestamp, $value, $callstack = '') { if (!$this->enabled) { return; @@ -75,8 +75,6 @@ class Profiler implements ContainerInterface $this->performance[$value] += (float) $duration; $this->performance['marktime'] += (float) $duration; - $callstack = Core\System::callstack(); - if (!isset($this->callstack[$value][$callstack])) { // Prevent ugly E_NOTICE $this->callstack[$value][$callstack] = 0;