Simplify format_time()
This commit is contained in:
parent
95b0237061
commit
fc668ea326
|
@ -142,7 +142,7 @@ if (isset($_GET["elastic"])) {
|
|||
$start = microtime(true);
|
||||
$search = $this->_conn->query($query, $data);
|
||||
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) {
|
||||
return false;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
$start = microtime(true);
|
||||
$return = $this->_conn->query($query);
|
||||
if ($print) {
|
||||
echo $adminer->selectQuery($query, format_time($start, microtime(true)));
|
||||
echo $adminer->selectQuery($query, format_time($start));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
|
|
@ -553,7 +553,7 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
|
|||
if ($execute) {
|
||||
$start = microtime(true);
|
||||
$failed = !$connection->query($query);
|
||||
$time = format_time($start, microtime(true));
|
||||
$time = format_time($start);
|
||||
}
|
||||
$sql = "";
|
||||
if ($query) {
|
||||
|
@ -571,7 +571,7 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
|
|||
|
||||
/** Execute and remember query
|
||||
* @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) {
|
||||
global $connection;
|
||||
|
@ -582,7 +582,7 @@ function queries($query) {
|
|||
}
|
||||
if ($query === null) {
|
||||
// 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) . ";";
|
||||
return $connection->query($query);
|
||||
|
@ -614,13 +614,12 @@ function queries_redirect($location, $message, $redirect) {
|
|||
return query_redirect($queries, $location, $message, $redirect, false, !$redirect, $time);
|
||||
}
|
||||
|
||||
/** Format time difference
|
||||
* @param string output of microtime(true)
|
||||
* @param string output of microtime(true)
|
||||
/** Format elapsed time
|
||||
* @param float output of microtime(true)
|
||||
* @return string HTML code
|
||||
*/
|
||||
function format_time($start, $end) {
|
||||
return lang('%.3f s', max(0, $end - $start));
|
||||
function format_time($start) {
|
||||
return lang('%.3f s', max(0, microtime(true) - $start));
|
||||
}
|
||||
|
||||
/** Remove parameter from query string
|
||||
|
|
|
@ -108,8 +108,7 @@ if (!$error && $_POST) {
|
|||
|
||||
do {
|
||||
$result = $connection->store_result();
|
||||
$end = microtime(true);
|
||||
$time = " <span class='time'>(" . format_time($start, $end) . ")</span>"
|
||||
$time = " <span class='time'>(" . format_time($start) . ")</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
|
||||
;
|
||||
|
||||
|
@ -156,7 +155,7 @@ if (!$error && $_POST) {
|
|||
}
|
||||
}
|
||||
|
||||
$start = $end;
|
||||
$start = microtime(true);
|
||||
} while ($connection->next_result());
|
||||
|
||||
$line += substr_count($q.$found, "\n");
|
||||
|
@ -172,7 +171,7 @@ if (!$error && $_POST) {
|
|||
echo "<p class='message'>" . lang('No commands to execute.') . "\n";
|
||||
} elseif ($_POST["only_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) {
|
||||
echo "<p class='error'>" . lang('Error in query') . ": " . implode("", $errors) . "\n";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue