Switch to hrtime and display time to render in ms

This commit is contained in:
Belle Aerni 2023-06-20 05:20:24 -07:00
parent 8d9e894af8
commit c613271c48
2 changed files with 5 additions and 7 deletions

View file

@ -81,8 +81,8 @@ class AntAuth
{
setcookie("auth", "valid");
$title = AntConfig::currentConfig('siteInfo.siteTitle');
header('WWW-Authenticate: Basic realm="' . $title . '"');
$siteInfo = AntConfig::currentConfig('siteInfo');
header('WWW-Authenticate: Basic realm="' . $siteInfo['siteTitle'] . '"');
http_response_code(401);
echo 'You must enter a valid username and password to access this page';
exit;

View file

@ -23,7 +23,7 @@ class AntCMS
*/
public function renderPage(string $page)
{
$start_time = microtime(true);
$start_time = hrtime(true);
$content = $this->getPage($page);
$themeConfig = Self::getThemeConfig();
@ -43,12 +43,10 @@ class AntCMS
];
$pageTemplate = $this->antTwig->renderWithTiwg($pageTemplate, $params);
$end_time = microtime(true);
$elapsed_time = round($end_time - $start_time, 4);
$elapsed_time = (hrtime(true) - $start_time) / 1e+6;
if (AntConfig::currentConfig('debug')) {
$pageTemplate = str_replace('<!--AntCMS-Debug-->', '<p>Took ' . $elapsed_time . ' seconds to render the page. </p>', $pageTemplate);
$pageTemplate = str_replace('<!--AntCMS-Debug-->', '<p>Took ' . $elapsed_time . ' milliseconds to render the page. </p>', $pageTemplate);
}
return $pageTemplate;