From 781b7240c41ddd141cfb057480c10d9cee30e6d7 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 4 May 2025 20:16:58 +0300 Subject: [PATCH] fix: Incorrect rounding in execution time counter (#1899) * fix: Incorrect rounding in execution time counter * Update page_footer.php --- admin/stats/tr_stats.php | 2 +- admin/stats/tracker.php | 2 +- library/includes/page_footer.php | 4 ++-- src/Dev.php | 2 +- src/Legacy/SqlDb.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/admin/stats/tr_stats.php b/admin/stats/tr_stats.php index 591b675c6..4cd8733c3 100644 --- a/admin/stats/tr_stats.php +++ b/admin/stats/tr_stats.php @@ -39,7 +39,7 @@ foreach ($sql as $i => $query) { echo ''; echo '
';
 
-echo 'gen time: ' . sprintf('%.4f', array_sum(explode(' ', microtime())) - TIMESTART) . " sec\n";
+echo 'gen time: ' . sprintf('%.3f', array_sum(explode(' ', microtime())) - TIMESTART) . " sec\n";
 
 echo '
'; echo ''; diff --git a/admin/stats/tracker.php b/admin/stats/tracker.php index 102436bcb..977856b4c 100644 --- a/admin/stats/tracker.php +++ b/admin/stats/tracker.php @@ -173,7 +173,7 @@ echo ''; echo !$client_full ? '

Simple stats for clients are being cached for one hour.

' : ''; echo '
';
 
-echo 'gen time: ' . sprintf('%.4f', array_sum(explode(' ', microtime())) - TIMESTART) . " sec\n";
+echo 'gen time: ' . sprintf('%.3f', array_sum(explode(' ', microtime())) - TIMESTART) . " sec\n";
 echo '
'; echo ''; diff --git a/library/includes/page_footer.php b/library/includes/page_footer.php index 15b1023b3..2eadbe6f2 100644 --- a/library/includes/page_footer.php +++ b/library/includes/page_footer.php @@ -35,7 +35,7 @@ if (!$bb_cfg['gzip_compress']) { if ($show_dbg_info) { $gen_time = utime() - TIMESTART; - $gen_time_txt = sprintf('%.4f', $gen_time); + $gen_time_txt = sprintf('%.3f', $gen_time); $gzip_text = UA_GZIP_SUPPORTED ? "{$lang['GZIP_COMPRESSION']}: " : "{$lang['GZIP_COMPRESSION']}: "; $gzip_text .= $bb_cfg['gzip_compress'] ? $lang['ON'] : $lang['OFF']; @@ -43,7 +43,7 @@ if ($show_dbg_info) { if (!empty($DBS)) { $sql_t = $DBS->sql_timetotal; - $sql_time_txt = ($sql_t) ? sprintf('%.4f ' . $lang['SEC'] . ' (%d%%) · ', $sql_t, round($sql_t * 100 / $gen_time)) : ''; + $sql_time_txt = ($sql_t) ? sprintf('%.3f ' . $lang['SEC'] . ' (%d%%) · ', $sql_t, round($sql_t * 100 / $gen_time)) : ''; $num_q = $DBS->num_queries; $stat .= "  |  {$DBS->get_db_obj()->engine}: {$sql_time_txt}{$num_q} " . $lang['QUERIES']; } diff --git a/src/Dev.php b/src/Dev.php index a4ce7f7f0..e1539eb03 100644 --- a/src/Dev.php +++ b/src/Dev.php @@ -230,7 +230,7 @@ class Dev foreach ($db_obj->dbg as $i => $dbg) { $id = "sql_{$i}_" . random_int(0, mt_getrandmax()); $sql = self::shortQuery($dbg['sql'], true); - $time = sprintf('%.4f', $dbg['time']); + $time = sprintf('%.3f', $dbg['time']); $perc = '[' . round($dbg['time'] * 100 / $db_obj->sql_timetotal) . '%]'; $info = !empty($dbg['info']) ? $dbg['info'] . ' [' . $dbg['src'] . ']' : $dbg['src']; diff --git a/src/Legacy/SqlDb.php b/src/Legacy/SqlDb.php index 3fa1dbab8..366108923 100644 --- a/src/Legacy/SqlDb.php +++ b/src/Legacy/SqlDb.php @@ -832,7 +832,7 @@ class SqlDb */ public function log_query($log_file = 'sql_queries') { - $q_time = ($this->cur_query_time >= 10) ? round($this->cur_query_time, 0) : sprintf('%.4f', $this->cur_query_time); + $q_time = ($this->cur_query_time >= 10) ? round($this->cur_query_time, 0) : sprintf('%.3f', $this->cur_query_time); $msg = []; $msg[] = round($this->sql_starttime); $msg[] = date('m-d H:i:s', (int)$this->sql_starttime); @@ -943,7 +943,7 @@ class SqlDb $this->explain_out .= ' - +
 ' . $dbg['src'] . '  [' . sprintf('%.4f', $dbg['time']) . ' s]  ' . $dbg['info'] . ' ' . $dbg['src'] . '  [' . sprintf('%.3f', $dbg['time']) . ' s]  ' . $dbg['info'] . ' ' . "[$this->engine] $this->db_server.$this->selected_db" . ' :: Query #' . ($this->num_queries + 1) . ' 
' . $this->explain_hold . '