1
0
Fork 0

Generate callstack value from inside Profiler::saveTimestamp

- Save a massive amount of time computing callstacks when profiling is disabled
This commit is contained in:
Hypolite Petovan 2020-07-27 00:22:07 -04:00
commit afb882048e
13 changed files with 42 additions and 39 deletions

View file

@ -23,6 +23,7 @@ namespace Friendica\Util;
use Friendica\Core\Config\Cache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\System;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
@ -88,9 +89,9 @@ class Profiler implements ContainerInterface
* Saves a timestamp for a value - f.e. a call
* Necessary for profiling Friendica
*
* @param int $timestamp the Timestamp
* @param string $value A value to profile
* @param string $callstack The callstack of the current profiling data
* @param int $timestamp the Timestamp
* @param string $value A value to profile
* @param string $callstack A callstack string, generated if absent
*/
public function saveTimestamp($timestamp, $value, $callstack = '')
{
@ -98,6 +99,8 @@ class Profiler implements ContainerInterface
return;
}
$callstack = $callstack ?: System::callstack(4, 1);
$duration = floatval(microtime(true) - $timestamp);
if (!isset($this->performance[$value])) {