From 902b931b89a160faf62f88d76b235566f865fa91 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 29 Jun 2020 22:30:48 +0900 Subject: [PATCH] Provide methods to tell total elapsed time --- common/framework/db.php | 20 ++++++++++++++++++++ common/framework/debug.php | 5 +++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/common/framework/db.php b/common/framework/db.php index ba556e613..1443fe05c 100644 --- a/common/framework/db.php +++ b/common/framework/db.php @@ -947,6 +947,26 @@ class DB Debug::addQuery($log); } + /** + * Get total time spent during queries. + * + * @return float + */ + public function getQueryElapsedTime() + { + return $this->_query_time; + } + + /** + * Get total time spent in this class. + * + * @return float + */ + public function getTotalElapsedTime() + { + return $this->_total_time; + } + /** * ========================== DEPRECATED METHODS ========================== * ==================== KEPT FOR COMPATIBILITY WITH XE ==================== diff --git a/common/framework/debug.php b/common/framework/debug.php index f9ce31076..37b2646a2 100644 --- a/common/framework/debug.php +++ b/common/framework/debug.php @@ -746,6 +746,7 @@ class Debug public static function getDebugData() { // Collect debug information. + $db = DB::getInstance(); $data = (object)array( 'timestamp' => DateTime::formatTimestamp('Y-m-d H:i:s', \RX_TIME), 'url' => getCurrentPageUrl(), @@ -761,8 +762,8 @@ class Debug 'total' => sprintf('%0.4f sec', microtime(true) - \RX_MICROTIME), 'template' => sprintf('%0.4f sec (count: %d)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']), 'xmlparse' => sprintf('%0.4f sec', $GLOBALS['__xmlparse_elapsed__']), - 'db_query' => sprintf('%0.4f sec (count: %d)', $GLOBALS['__db_elapsed_time__'], count(self::$_queries)), - 'db_class' => sprintf('%0.4f sec', $GLOBALS['__dbclass_elapsed_time__'] - $GLOBALS['__db_elapsed_time__']), + 'db_query' => sprintf('%0.4f sec (count: %d)', $db->getQueryElapsedTime(), count(self::$_queries)), + 'db_class' => sprintf('%0.4f sec', $db->getTotalElapsedTime() - $db->getQueryElapsedTime()), 'layout' => sprintf('%0.4f sec', $GLOBALS['__layout_compile_elapsed__']), 'widget' => sprintf('%0.4f sec', $GLOBALS['__widget_excute_elapsed__']), 'remote' => sprintf('%0.4f sec', $GLOBALS['__remote_request_elapsed__']),