SOLR-4384: Make post.jar report timing information

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1440746 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jan Høydahl 2013-01-31 00:26:11 +00:00
parent 4bd78bb389
commit c1024f192e
2 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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,8 +181,28 @@ 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