Simplify format_time()
This commit is contained in:
parent
95b0237061
commit
fc668ea326
|
@ -142,7 +142,7 @@ if (isset($_GET["elastic"])) {
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
$search = $this->_conn->query($query, $data);
|
$search = $this->_conn->query($query, $data);
|
||||||
if ($print) {
|
if ($print) {
|
||||||
echo $adminer->selectQuery("$query: " . print_r($data, true), format_time($start, microtime(true)));
|
echo $adminer->selectQuery("$query: " . print_r($data, true), format_time($start));
|
||||||
}
|
}
|
||||||
if (!$search) {
|
if (!$search) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
$return = $this->_conn->query($query);
|
$return = $this->_conn->query($query);
|
||||||
if ($print) {
|
if ($print) {
|
||||||
echo $adminer->selectQuery($query, format_time($start, microtime(true)));
|
echo $adminer->selectQuery($query, format_time($start));
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -553,7 +553,7 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
|
||||||
if ($execute) {
|
if ($execute) {
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
$failed = !$connection->query($query);
|
$failed = !$connection->query($query);
|
||||||
$time = format_time($start, microtime(true));
|
$time = format_time($start);
|
||||||
}
|
}
|
||||||
$sql = "";
|
$sql = "";
|
||||||
if ($query) {
|
if ($query) {
|
||||||
|
@ -571,7 +571,7 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
|
||||||
|
|
||||||
/** Execute and remember query
|
/** Execute and remember query
|
||||||
* @param string or null to return remembered queries, end with ';' to use DELIMITER
|
* @param string or null to return remembered queries, end with ';' to use DELIMITER
|
||||||
* @return Min_Result or string if $query = null
|
* @return Min_Result or array($queries, $time) if $query = null
|
||||||
*/
|
*/
|
||||||
function queries($query) {
|
function queries($query) {
|
||||||
global $connection;
|
global $connection;
|
||||||
|
@ -582,7 +582,7 @@ function queries($query) {
|
||||||
}
|
}
|
||||||
if ($query === null) {
|
if ($query === null) {
|
||||||
// return executed queries
|
// return executed queries
|
||||||
return array(implode("\n", $queries), format_time($start, microtime(true)));
|
return array(implode("\n", $queries), format_time($start));
|
||||||
}
|
}
|
||||||
$queries[] = (preg_match('~;$~', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query) . ";";
|
$queries[] = (preg_match('~;$~', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query) . ";";
|
||||||
return $connection->query($query);
|
return $connection->query($query);
|
||||||
|
@ -614,13 +614,12 @@ function queries_redirect($location, $message, $redirect) {
|
||||||
return query_redirect($queries, $location, $message, $redirect, false, !$redirect, $time);
|
return query_redirect($queries, $location, $message, $redirect, false, !$redirect, $time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Format time difference
|
/** Format elapsed time
|
||||||
* @param string output of microtime(true)
|
* @param float output of microtime(true)
|
||||||
* @param string output of microtime(true)
|
|
||||||
* @return string HTML code
|
* @return string HTML code
|
||||||
*/
|
*/
|
||||||
function format_time($start, $end) {
|
function format_time($start) {
|
||||||
return lang('%.3f s', max(0, $end - $start));
|
return lang('%.3f s', max(0, microtime(true) - $start));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove parameter from query string
|
/** Remove parameter from query string
|
||||||
|
|
|
@ -108,8 +108,7 @@ if (!$error && $_POST) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$result = $connection->store_result();
|
$result = $connection->store_result();
|
||||||
$end = microtime(true);
|
$time = " <span class='time'>(" . format_time($start) . ")</span>"
|
||||||
$time = " <span class='time'>(" . format_time($start, $end) . ")</span>"
|
|
||||||
. (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : "") // 1000 - maximum length of encoded URL in IE is 2083 characters
|
. (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : "") // 1000 - maximum length of encoded URL in IE is 2083 characters
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -156,7 +155,7 @@ if (!$error && $_POST) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = $end;
|
$start = microtime(true);
|
||||||
} while ($connection->next_result());
|
} while ($connection->next_result());
|
||||||
|
|
||||||
$line += substr_count($q.$found, "\n");
|
$line += substr_count($q.$found, "\n");
|
||||||
|
@ -172,7 +171,7 @@ if (!$error && $_POST) {
|
||||||
echo "<p class='message'>" . lang('No commands to execute.') . "\n";
|
echo "<p class='message'>" . lang('No commands to execute.') . "\n";
|
||||||
} elseif ($_POST["only_errors"]) {
|
} elseif ($_POST["only_errors"]) {
|
||||||
echo "<p class='message'>" . lang('%d query(s) executed OK.', $commands - count($errors));
|
echo "<p class='message'>" . lang('%d query(s) executed OK.', $commands - count($errors));
|
||||||
echo " <span class='time'>(" . format_time($total_start, microtime(true)) . ")</span>\n";
|
echo " <span class='time'>(" . format_time($total_start) . ")</span>\n";
|
||||||
} elseif ($errors && $commands > 1) {
|
} elseif ($errors && $commands > 1) {
|
||||||
echo "<p class='error'>" . lang('Error in query') . ": " . implode("", $errors) . "\n";
|
echo "<p class='error'>" . lang('Error in query') . ": " . implode("", $errors) . "\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue