Dependency of callstack moved one layer up

This commit is contained in:
Philipp Holzer 2019-02-16 23:17:10 +01:00
parent 5e6e1a8025
commit 0a7861da65
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
12 changed files with 39 additions and 40 deletions

View file

@ -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 {

View file

@ -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);

View file

@ -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('/<a(.*?)href="#/is', '<a$1href="' . ltrim($_SERVER['REQUEST_URI'], '/') . '#', $html);
self::getApp()->getProfiler()->saveTimestamp($stamp1, "parser");
self::getApp()->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack());
return $html;
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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());
}
}

View file

@ -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;
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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);

View file

@ -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;

View file

@ -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;