use Dice\Dice;
+$start_time = microtime(true);
+
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
die('Vendor path not found. Please execute "bin/composer.phar --no-dev install" on the command line in the web root.');
}
$dice->create(\Friendica\App\Router::class),
$dice->create(\Friendica\Core\PConfig\IPConfig::class),
$dice->create(\Friendica\Security\Authentication::class),
- $dice->create(\Friendica\App\Page::class)
+ $dice->create(\Friendica\App\Page::class),
+ $start_time
);
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
- public function runFrontend(App\Module $module, App\Router $router, IPConfig $pconfig, Authentication $auth, App\Page $page)
+ public function runFrontend(App\Module $module, App\Router $router, IPConfig $pconfig, Authentication $auth, App\Page $page, int $start_time = 0)
{
+ if ($start_time != 0) {
+ $this->profiler->set($start_time, 'start');
+ }
+
+ $this->profiler->set(microtime(true), 'classinit');
+
$moduleName = $module->getName();
try {
$module = $module->determineClass($this->args, $router, $this->config);
// Let the module run it's internal process (init, get, post, ...)
- $module->run($this->l10n, $this->baseURL, $this->logger, $_SERVER, $_POST);
+ $module->run($this->l10n, $this->baseURL, $this->logger, $this->profiler, $_SERVER, $_POST);
} catch (HTTPException $e) {
ModuleHTTPException::rawContent($e);
}
- $page->run($this, $this->baseURL, $this->mode, $module, $this->l10n, $this->config, $pconfig);
+ $page->run($this, $this->baseURL, $this->mode, $module, $this->l10n, $this->profiler, $this->config, $pconfig);
}
/**
use Friendica\Module\HTTPException\PageNotFound;
use Friendica\Network\HTTPException\MethodNotAllowedException;
use Friendica\Network\HTTPException\NotFoundException;
+use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
/**
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function run(Core\L10n $l10n, App\BaseURL $baseUrl, LoggerInterface $logger, array $server, array $post)
+ public function run(Core\L10n $l10n, App\BaseURL $baseUrl, LoggerInterface $logger, Profiler $profiler, array $server, array $post)
{
if ($this->printNotAllowedAddon) {
notice($l10n->t("You must be logged in to use addons. "));
$placeholder = '';
+ $profiler->set(microtime(true), 'ready');
+ $timestamp = microtime(true);
+
Core\Hook::callAll($this->module . '_mod_init', $placeholder);
call_user_func([$this->module_class, 'init'], $this->module_parameters);
+ $profiler->set(microtime(true) - $timestamp, 'init');
+
if ($server['REQUEST_METHOD'] === 'POST') {
Core\Hook::callAll($this->module . '_mod_post', $post);
call_user_func([$this->module_class, 'post'], $this->module_parameters);
use Friendica\Network\HTTPException;
use Friendica\Util\Network;
use Friendica\Util\Strings;
+use Friendica\Util\Profiler;
/**
* Contains the page specific environment variables for the current Page
*
* @throws HTTPException\InternalServerErrorException
*/
- public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfig $config, IPConfig $pconfig)
+ public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, Profiler $profiler, IConfig $config, IPConfig $pconfig)
{
$moduleName = $module->getName();
*
* Sets the $Page->page['content'] variable
*/
+ $timestamp = microtime(true);
$this->initContent($module, $mode);
+ $profiler->set(microtime(true) - $timestamp, 'content');
// Load current theme info after module has been initialized as theme could have been set in module
$currentTheme = $app->getCurrentTheme();
public function resetPerformance()
{
$this->performance = [];
- $this->performance['start'] = microtime(true);
+ $this->performance['start'] = $this->performance['ready'] = microtime(true);
$this->performance['database'] = 0;
$this->performance['database_write'] = 0;
$this->performance['cache'] = 0;
$this->performance['parser'] = 0;
$this->performance['marktime'] = 0;
$this->performance['marktime'] = microtime(true);
+ $this->performance['frontend'] = 0;
+ $this->performance['init'] = 0;
+ $this->performance['content'] = 0;
}
/**
}
}
+ public function set($timestamp, $id)
+ {
+ $this->performance[$id] = $timestamp;
+ }
+
/**
* Returns true if the container can return an entry for the given identifier.
* Returns false otherwise.