lucene-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1440746&view=rev
Log:
SOLR-4384: Make post.jar report timing information

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/SimplePostTool.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1440746&r1=1440745&r2=1440746&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Thu Jan 31 00:26:11 2013
@@ -130,6 +130,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/trunk/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/SimplePostTool.java?rev=1440746&r1=1440745&r2=1440746&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/SimplePostTool.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/SimplePostTool.java Thu Jan 31
00:26:11 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