From 78d34767d0aa7e61c7c1ab33fbd9e15113ce8d65 Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Mon, 24 Feb 2003 16:19:15 +0000 Subject: [PATCH] Measures basic query time [#571934] --- libraries/display_tbl.lib.php3 | 2 +- sql.php3 | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libraries/display_tbl.lib.php3 b/libraries/display_tbl.lib.php3 index 76ebd6c70..097a81020 100644 --- a/libraries/display_tbl.lib.php3 +++ b/libraries/display_tbl.lib.php3 @@ -1431,7 +1431,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { $last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' || $pos_next > $total) ? $total - 1 : $pos_next - 1; - PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec ($total " . $GLOBALS['strTotal'] . $selectstring . ')'); + PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec ($total " . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')'); } else if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { PMA_showMessage($GLOBALS['strSQLQuery']); } diff --git a/sql.php3 b/sql.php3 index 4ee010211..c8c3cde49 100755 --- a/sql.php3 +++ b/sql.php3 @@ -296,8 +296,17 @@ else { $num_rows = 0; } else { + // garvin: Measure query time. TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411 + list($usec, $sec) = explode(' ',microtime()); + $querytime_before = ((float)$usec + (float)$sec); + $result = @PMA_mysql_query($full_sql_query); + list($usec, $sec) = explode(' ',microtime()); + $querytime_after = ((float)$usec + (float)$sec); + + $GLOBALS['querytime'] = $querytime_after - $querytime_before; + // Displays an error message if required and stop parsing the script if (PMA_mysql_error()) { $error = PMA_mysql_error(); @@ -449,6 +458,8 @@ else { $message = $strEmptyResultSet; } + $message .= " (" . sprintf($strQueryTime, $GLOBALS['querytime']) . ")"; + if ($is_gotofile) { $goto = ereg_replace('\.\.*', '.', $goto); // Checks for a valid target script