]> git.joonet.de Git - adminer.git/commitdiff
Simplify format_time()
authorJakub Vrana <jakub@vrana.cz>
Tue, 11 Mar 2014 16:37:56 +0000 (09:37 -0700)
committerJakub Vrana <jakub@vrana.cz>
Sat, 15 Mar 2014 18:02:14 +0000 (11:02 -0700)
adminer/drivers/elastic.inc.php
adminer/include/driver.inc.php
adminer/include/functions.inc.php
adminer/sql.inc.php

index 289f90225ebdec897d26c7042bd47de06e6d774a..822ccf70b92e19c7b9482cd5a6bc489839cce98e 100644 (file)
@@ -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;
index c0b4b9ad24ac56554844b7acf8baf4d1ad8c1594..abedc6042e2676d94bd21759de139724a8b1ad18 100644 (file)
@@ -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;
        }
index 44618a569023b794ddc4d2ea3f9bb8f5f341a6a2..ac8d2d4dfccc6eb5e5d45d1e3a6aedf4d99cc67e 100644 (file)
@@ -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
index 636e6d72a26207992e95122b2430ba8710b54fa9..1158ceaab8370a715de70077466d191411b8e1e2 100644 (file)
@@ -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";
                }