lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jan...@apache.org
Subject svn commit: r1440755 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/java/org/apache/solr/util/SimplePostTool.java
Date Thu, 31 Jan 2013 00:35:10 GMT
Author: janhoy
Date: Thu Jan 31 00:35:10 2013
New Revision: 1440755

URL: http://svn.apache.org/viewvc?rev=1440755&view=rev
Log:
SOLR-4384: Make post.jar report timing information (merge from trunk)

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/util/SimplePostTool.java

Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1440755&r1=1440754&r2=1440755&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Thu Jan 31 00:35:10 2013
@@ -108,6 +108,8 @@ Other Changes
 
 * SOLR-4353: Renamed example jetty context file to reduce confusion (hossman)
 
+* SOLR-4384: Make post.jar report timing information (Upayavira via janhoy)
+
 ==================  4.1.0 ==================
 
 Versions of Major Components

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/util/SimplePostTool.java?rev=1440755&r1=1440754&r2=1440755&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
Thu Jan 31 00:35:10 2013
@@ -165,6 +165,7 @@ public class SimplePostTool {
    * This method delegates to the correct mode method.
    */
   public void execute() {
+    final long startTime = System.currentTimeMillis();
     if (DATA_MODE_FILES.equals(mode) && args.length > 0) {
       doFilesMode();
     } else if(DATA_MODE_ARGS.equals(mode) && args.length > 0) {
@@ -180,9 +181,29 @@ public class SimplePostTool {
     
     if (commit)   commit();
     if (optimize) optimize();
+    final long endTime = System.currentTimeMillis();
+    displayTiming(endTime - startTime);
   }
   
   /**
+   * Pretty prints the number of milliseconds taken to post the content to Solr
+   * @param millis the time in milliseconds
+   */
+  private void displayTiming(long millis) {
+    long hours = millis / 3600000;
+    long minutes = (millis / 60000) % 60;
+    long seconds = (millis / 1000) % 60;
+    long milliseconds = millis % 1000;
+    if (hours>0) {
+      System.out.println(String.format("Time taken: %02d:%02d:%02d.%03d", hours, minutes,
seconds, milliseconds));
+    } else if (minutes>0) {
+      System.out.println(String.format("Time taken: %02d:%02d.%03d", minutes, seconds, milliseconds));
+    } else {
+      System.out.println(String.format("Time taken: %d.%03ds", seconds, milliseconds));
+    }
+ }
+
+  /**
    * Parses incoming arguments and system params and initializes the tool
    * @param args the incoming cmd line args
    * @return an instance of SimplePostTool



Mime
View raw message