Simplify format_time()
This commit is contained in:
parent
85d212c226
commit
28856804a4
|
@ -522,9 +522,9 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
|
||||||
global $connection, $error, $adminer;
|
global $connection, $error, $adminer;
|
||||||
$time = "";
|
$time = "";
|
||||||
if ($execute) {
|
if ($execute) {
|
||||||
$start = microtime();
|
$start = microtime(true);
|
||||||
$failed = !$connection->query($query);
|
$failed = !$connection->query($query);
|
||||||
$time = "; -- " . format_time($start, microtime());
|
$time = "; -- " . format_time($start, microtime(true));
|
||||||
}
|
}
|
||||||
$sql = "";
|
$sql = "";
|
||||||
if ($query) {
|
if ($query) {
|
||||||
|
@ -551,10 +551,10 @@ function queries($query = null) {
|
||||||
// return executed queries without parameter
|
// return executed queries without parameter
|
||||||
return implode("\n", $queries);
|
return implode("\n", $queries);
|
||||||
}
|
}
|
||||||
$start = microtime();
|
$start = microtime(true);
|
||||||
$return = $connection->query($query);
|
$return = $connection->query($query);
|
||||||
$queries[] = (preg_match('~;$~', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query)
|
$queries[] = (preg_match('~;$~', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query)
|
||||||
. "; -- " . format_time($start, microtime());
|
. "; -- " . format_time($start, microtime(true));
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,12 +584,12 @@ function queries_redirect($location, $message, $redirect) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Format time difference
|
/** Format time difference
|
||||||
* @param string output of microtime()
|
* @param string output of microtime(true)
|
||||||
* @param string output of microtime()
|
* @param string output of microtime(true)
|
||||||
* @return string HTML code
|
* @return string HTML code
|
||||||
*/
|
*/
|
||||||
function format_time($start, $end) {
|
function format_time($start, $end) {
|
||||||
return lang('%.3f s', max(0, array_sum(explode(" ", $end)) - array_sum(explode(" ", $start))));
|
return lang('%.3f s', max(0, $end - $start));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove parameter from query string
|
/** Remove parameter from query string
|
||||||
|
|
|
@ -57,7 +57,7 @@ if (!$error && $_POST) {
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$line = 0;
|
$line = 0;
|
||||||
$parse = '[\'"' . ($jush == "sql" ? '`#' : ($jush == "sqlite" ? '`[' : ($jush == "mssql" ? '[' : ''))) . ']|/\\*|-- |$' . ($jush == "pgsql" ? '|\\$[^$]*\\$' : '');
|
$parse = '[\'"' . ($jush == "sql" ? '`#' : ($jush == "sqlite" ? '`[' : ($jush == "mssql" ? '[' : ''))) . ']|/\\*|-- |$' . ($jush == "pgsql" ? '|\\$[^$]*\\$' : '');
|
||||||
$total_start = microtime();
|
$total_start = microtime(true);
|
||||||
parse_str($_COOKIE["adminer_export"], $adminer_export);
|
parse_str($_COOKIE["adminer_export"], $adminer_export);
|
||||||
$dump_format = $adminer->dumpFormat();
|
$dump_format = $adminer->dumpFormat();
|
||||||
unset($dump_format["sql"]);
|
unset($dump_format["sql"]);
|
||||||
|
@ -100,7 +100,7 @@ if (!$error && $_POST) {
|
||||||
ob_flush();
|
ob_flush();
|
||||||
flush(); // can take a long time - show the running query
|
flush(); // can take a long time - show the running query
|
||||||
}
|
}
|
||||||
$start = microtime(); // microtime(true) is available since PHP 5
|
$start = microtime(true);
|
||||||
//! don't allow changing of character_set_results, convert encoding of displayed query
|
//! don't allow changing of character_set_results, convert encoding of displayed query
|
||||||
if ($connection->multi_query($q) && is_object($connection2) && preg_match("~^$space*USE\\b~isU", $q)) {
|
if ($connection->multi_query($q) && is_object($connection2) && preg_match("~^$space*USE\\b~isU", $q)) {
|
||||||
$connection2->query($q);
|
$connection2->query($q);
|
||||||
|
@ -108,7 +108,7 @@ if (!$error && $_POST) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$result = $connection->store_result();
|
$result = $connection->store_result();
|
||||||
$end = microtime();
|
$end = microtime(true);
|
||||||
$time = " <span class='time'>(" . format_time($start, $end) . ")</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
|
||||||
;
|
;
|
||||||
|
@ -172,7 +172,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()) . ")</span>\n";
|
echo " <span class='time'>(" . format_time($total_start, microtime(true)) . ")</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