Log the execution time

This commit is contained in:
Michael 2022-05-17 20:47:23 +00:00
parent 6eb70bea16
commit 4016a576d5
27 changed files with 67 additions and 6 deletions

View file

@ -30,6 +30,7 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Theme;
@ -78,14 +79,31 @@ class Page implements ArrayAccess
*/
private $basePath;
private $timestamp = 0;
private $moduleName = '';
private $method = '';
/**
* @param string $basepath The Page basepath
*/
public function __construct(string $basepath)
{
$this->timestamp = microtime(true);
$this->basePath = $basepath;
}
public function setLogging(string $moduleName, string $method)
{
$this->moduleName = $moduleName;
$this->method = $method;
}
public function logRuntime()
{
$runtime = number_format(microtime(true) - $this->timestamp, 3);
Logger::debug('Runtime', ['method' => $this->method, 'module' => $this->moduleName, 'runtime' => $runtime]);
}
/**
* Whether a offset exists
*
@ -401,6 +419,7 @@ class Page implements ArrayAccess
}
echo $response->getBody();
$this->logRuntime();
}
/**
@ -421,6 +440,9 @@ class Page implements ArrayAccess
{
$moduleName = $args->getModuleName();
$this->moduleName = $moduleName;
$this->method = $args->getMethod();
/* Create the page content.
* Calls all hooks which are including content operations
*