From c613271c4897c63dfb3a539f625d97738315263d Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Tue, 20 Jun 2023 05:20:24 -0700 Subject: [PATCH] Switch to hrtime and display time to render in ms --- src/AntCMS/AntAuth.php | 4 ++-- src/AntCMS/AntCMS.php | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/AntCMS/AntAuth.php b/src/AntCMS/AntAuth.php index 4ee5b2c..a04389c 100644 --- a/src/AntCMS/AntAuth.php +++ b/src/AntCMS/AntAuth.php @@ -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; diff --git a/src/AntCMS/AntCMS.php b/src/AntCMS/AntCMS.php index e3e4cf4..c5abf02 100644 --- a/src/AntCMS/AntCMS.php +++ b/src/AntCMS/AntCMS.php @@ -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('', '

Took ' . $elapsed_time . ' seconds to render the page.

', $pageTemplate); + $pageTemplate = str_replace('', '

Took ' . $elapsed_time . ' milliseconds to render the page.

', $pageTemplate); } return $pageTemplate;