cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [3/3] git commit: display elapsed time in 2 fraction digits in cli; patch by Radim Kolar, reviewed by yukim for CASSANDRA-3460
Date Thu, 27 Sep 2012 22:01:41 GMT
display elapsed time in 2 fraction digits in cli; patch by Radim Kolar, reviewed by yukim for
CASSANDRA-3460


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c7ce11f0
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c7ce11f0
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c7ce11f0

Branch: refs/heads/cassandra-1.1
Commit: c7ce11f0031c81311a359de03380860fa4e366a5
Parents: 93bd3d8
Author: Yuki Morishita <yukim@apache.org>
Authored: Thu Sep 27 16:57:37 2012 -0500
Committer: Yuki Morishita <yukim@apache.org>
Committed: Thu Sep 27 16:57:37 2012 -0500

----------------------------------------------------------------------
 CHANGES.txt                                      |    1 +
 src/java/org/apache/cassandra/cli/CliClient.java |   28 +++++++++++++---
 2 files changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c7ce11f0/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e48fbfd..f598aa2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,7 @@
  * fix error when using ORDER BY with extended selections (CASSANDRA-4689)
  * (CQL3) Fix validation for IN queries for non-PK cols (CASSANDRA-4709)
  * fix re-created keyspace disappering after 1.1.5 upgrade (CASSANDRA-4698)
+ * (CLI) display elapsed time in 2 fraction digits (CASSANDRA-3460)
 Merged from 1.0:
  * Switch from NBHM to CHM in MessagingService's callback map, which
    prevents OOM in long-running instances (CASSANDRA-4708)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c7ce11f0/src/java/org/apache/cassandra/cli/CliClient.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cli/CliClient.java b/src/java/org/apache/cassandra/cli/CliClient.java
index d0fb543..b32b0f7 100644
--- a/src/java/org/apache/cassandra/cli/CliClient.java
+++ b/src/java/org/apache/cassandra/cli/CliClient.java
@@ -461,7 +461,7 @@ public class CliClient
             throws InvalidRequestException, UnavailableException, TimedOutException, TException,
IllegalAccessException, NotFoundException, InstantiationException, NoSuchFieldException
     {
 
-        long startTime = System.currentTimeMillis();
+        long startTime = System.nanoTime();
         ColumnParent parent = new ColumnParent(columnFamily);
         if(superColumnName != null)
             parent.setSuper_column(superColumnName);
@@ -565,7 +565,7 @@ public class CliClient
     {
         if (!CliMain.isConnected() || !hasKeySpace())
             return;
-        long startTime = System.currentTimeMillis();
+        long startTime = System.nanoTime();
         Tree columnFamilySpec = statement.getChild(0);
         String columnFamily = CliCompiler.getColumnFamily(columnFamilySpec, keyspacesMap.get(keySpace).cf_defs);
         ByteBuffer key = getKeyAsBytes(columnFamily, columnFamilySpec.getChild(1));
@@ -734,7 +734,7 @@ public class CliClient
         if (!CliMain.isConnected() || !hasKeySpace())
             return;
 
-        long startTime = System.currentTimeMillis();
+        long startTime = System.nanoTime();
 
         IndexClause clause = new IndexClause();
         String columnFamily = CliCompiler.getColumnFamily(statement, keyspacesMap.get(keySpace).cf_defs);
@@ -828,7 +828,7 @@ public class CliClient
         if (!CliMain.isConnected() || !hasKeySpace())
             return;
 
-        long startTime = System.currentTimeMillis();
+        long startTime = System.nanoTime();
         // ^(NODE_COLUMN_ACCESS <cf> <key> <column>)
         Tree columnFamilySpec = statement.getChild(0);
         Tree keyTree = columnFamilySpec.getChild(1); // could be a function or regular text
@@ -1323,7 +1323,7 @@ public class CliClient
         if (!CliMain.isConnected() || !hasKeySpace())
             return;
 
-        long startTime = System.currentTimeMillis();
+        long startTime = System.nanoTime();
 
         // extract column family
         String columnFamily = CliCompiler.getColumnFamily(statement, keyspacesMap.get(keySpace).cf_defs);
@@ -2968,9 +2968,25 @@ public class CliClient
         return false;
     }
 
+    /**
+     * Print elapsed time. Print 2 fraction digits if eta is under 10 ms.
+     * @param startTime starting time in nanoseconds
+     */
     private void elapsedTime(long startTime)
     {
-        sessionState.out.println("Elapsed time: " + (System.currentTimeMillis() - startTime)
+ " msec(s).");
+        /** time elapsed in nanoseconds */
+        long eta = System.nanoTime() - startTime;
+
+        sessionState.out.print("Elapsed time: ");
+        if (eta < 10000000)
+        {
+            sessionState.out.print(Math.round(eta/10000.0)/100.0);
+        }
+        else
+        {
+            sessionState.out.print(Math.round(eta/1000000.0));
+        }
+        sessionState.out.println(" msec(s).");
     }
     
     class CfAssumptions


Mime
View raw message