lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r520890 [2/2] - in /lucene/java/trunk/contrib/benchmark: ./ conf/ src/java/org/apache/lucene/benchmark/byTask/ src/java/org/apache/lucene/benchmark/byTask/feeds/ src/java/org/apache/lucene/benchmark/byTask/stats/ src/java/org/apache/lucene/...
Date Wed, 21 Mar 2007 13:52:39 GMT
Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java
Wed Mar 21 06:52:34 2007
@@ -17,12 +17,17 @@
  * limitations under the License.
  */
 
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+
 import org.apache.lucene.benchmark.byTask.PerfRunData;
 import org.apache.lucene.benchmark.byTask.stats.Report;
+import org.apache.lucene.benchmark.byTask.stats.TaskStats;
 
 /**
  * Report all statistics aggregated by name.
- * Other side effects: None.
+ * <br>Other side effects: None.
  */
 public class RepSumByNameTask extends ReportTask {
 
@@ -31,7 +36,7 @@
   }
 
   public int doLogic() throws Exception {
-    Report rp = getRunData().getPoints().reportSumByName();
+    Report rp = reportSumByName(getRunData().getPoints().taskStats());
 
     System.out.println();
     System.out.println("------------> Report Sum By (any) Name ("+
@@ -42,4 +47,35 @@
     return 0;
   }
 
+  /**
+   * Report statistics as a string, aggregate for tasks named the same.
+   * @return the report
+   */
+  protected Report reportSumByName(List taskStats) {
+    // aggregate by task name
+    int reported = 0;
+    LinkedHashMap p2 = new LinkedHashMap();
+    for (Iterator it = taskStats.iterator(); it.hasNext();) {
+      TaskStats stat1 = (TaskStats) it.next();
+      if (stat1.getElapsed()>=0) { // consider only tasks that ended
+        reported++;
+        String name = stat1.getTask().getName();
+        TaskStats stat2 = (TaskStats) p2.get(name);
+        if (stat2 == null) {
+          try {
+            stat2 = (TaskStats) stat1.clone();
+          } catch (CloneNotSupportedException e) {
+            throw new RuntimeException(e);
+          }
+          p2.put(name,stat2);
+        } else {
+          stat2.add(stat1);
+        }
+      }
+    }
+    // now generate report from secondary list p2    
+    return genPartialReport(reported, p2, taskStats.size());
+  }
+
+
 }

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java
Wed Mar 21 06:52:34 2007
@@ -17,12 +17,17 @@
  * limitations under the License.
  */
 
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+
 import org.apache.lucene.benchmark.byTask.PerfRunData;
 import org.apache.lucene.benchmark.byTask.stats.Report;
+import org.apache.lucene.benchmark.byTask.stats.TaskStats;
 
 /**
  * Report all prefix matching statistics grouped/aggregated by name and round.
- * Other side effects: None.
+ * <br>Other side effects: None.
  */
 public class RepSumByPrefRoundTask extends RepSumByPrefTask {
 
@@ -31,7 +36,7 @@
   }
 
   public int doLogic() throws Exception {
-    Report rp = getRunData().getPoints().reportSumByPrefixRound(prefix);
+    Report rp = reportSumByPrefixRound(getRunData().getPoints().taskStats());
     
     System.out.println();
     System.out.println("------------> Report sum by Prefix ("+prefix+") and Round ("+
@@ -42,4 +47,32 @@
     return 0;
   }
 
+  protected Report reportSumByPrefixRound(List taskStats) {
+    // aggregate by task name and by round
+    int reported = 0;
+    LinkedHashMap p2 = new LinkedHashMap();
+    for (Iterator it = taskStats.iterator(); it.hasNext();) {
+      TaskStats stat1 = (TaskStats) it.next();
+      if (stat1.getElapsed()>=0 && stat1.getTask().getName().startsWith(prefix))
{ // only ended tasks with proper name
+        reported++;
+        String name = stat1.getTask().getName();
+        String rname = stat1.getRound()+"."+name; // group by round
+        TaskStats stat2 = (TaskStats) p2.get(rname);
+        if (stat2 == null) {
+          try {
+            stat2 = (TaskStats) stat1.clone();
+          } catch (CloneNotSupportedException e) {
+            throw new RuntimeException(e);
+          }
+          p2.put(rname,stat2);
+        } else {
+          stat2.add(stat1);
+        }
+      }
+    }
+    // now generate report from secondary list p2    
+    return genPartialReport(reported, p2, taskStats.size());
+  }
+
+
 }

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java
Wed Mar 21 06:52:34 2007
@@ -19,10 +19,15 @@
 
 import org.apache.lucene.benchmark.byTask.PerfRunData;
 import org.apache.lucene.benchmark.byTask.stats.Report;
+import org.apache.lucene.benchmark.byTask.stats.TaskStats;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
 
 /**
  * Report by-name-prefix statistics aggregated by name.
- * Other side effects: None.
+ * <br>Other side effects: None.
  */
 public class RepSumByPrefTask extends ReportTask {
 
@@ -33,7 +38,7 @@
   protected String prefix;
 
   public int doLogic() throws Exception {
-    Report rp = getRunData().getPoints().reportSumByPrefix(prefix);
+    Report rp = reportSumByPrefix(getRunData().getPoints().taskStats());
     
     System.out.println();
     System.out.println("------------> Report Sum By Prefix ("+prefix+") ("+
@@ -43,6 +48,33 @@
 
     return 0;
   }
+
+  protected Report reportSumByPrefix (List taskStats) {
+    // aggregate by task name
+    int reported = 0;
+    LinkedHashMap p2 = new LinkedHashMap();
+    for (Iterator it = taskStats.iterator(); it.hasNext();) {
+      TaskStats stat1 = (TaskStats) it.next();
+      if (stat1.getElapsed()>=0 && stat1.getTask().getName().startsWith(prefix))
{ // only ended tasks with proper name
+        reported++;
+        String name = stat1.getTask().getName();
+        TaskStats stat2 = (TaskStats) p2.get(name);
+        if (stat2 == null) {
+          try {
+            stat2 = (TaskStats) stat1.clone();
+          } catch (CloneNotSupportedException e) {
+            throw new RuntimeException(e);
+          }
+          p2.put(name,stat2);
+        } else {
+          stat2.add(stat1);
+        }
+      }
+    }
+    // now generate report from secondary list p2    
+    return genPartialReport(reported, p2, taskStats.size());
+  }
+  
 
   public void setPrefix(String prefix) {
     this.prefix = prefix;

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReportTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReportTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReportTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReportTask.java
Wed Mar 21 06:52:34 2007
@@ -1,6 +1,12 @@
 package org.apache.lucene.benchmark.byTask.tasks;
 
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+
 import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.stats.Report;
+import org.apache.lucene.benchmark.byTask.stats.TaskStats;
+import org.apache.lucene.benchmark.byTask.utils.Format;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -41,4 +47,116 @@
   protected boolean shouldNotRecordStats() {
     return true;
   }
+
+  /*
+   * From here start the code used to generate the reports. 
+   * Subclasses would use this part to generate reports.
+   */
+  
+  protected static final String newline = System.getProperty("line.separator");
+  
+  /**
+   * Get a textual summary of the benchmark results, average from all test runs.
+   */
+  protected static final String OP =          "Operation  ";
+  protected static final String ROUND =       " round";
+  protected static final String RUNCNT =      "   runCnt";
+  protected static final String RECCNT =      "   recsPerRun";
+  protected static final String RECSEC =      "        rec/s";
+  protected static final String ELAPSED =     "  elapsedSec";
+  protected static final String USEDMEM =     "    avgUsedMem";
+  protected static final String TOTMEM =      "    avgTotalMem";
+  protected static final String COLS[] = {
+      RUNCNT,
+      RECCNT,
+      RECSEC,
+      ELAPSED,
+      USEDMEM,
+      TOTMEM
+  };
+
+  /**
+   * Compute a title line for a report table
+   * @param longestOp size of longest op name in the table
+   * @return the table title line.
+   */
+  protected String tableTitle (String longestOp) {
+    StringBuffer sb = new StringBuffer();
+    sb.append(Format.format(OP,longestOp));
+    sb.append(ROUND);
+    sb.append(getRunData().getConfig().getColsNamesForValsByRound());
+    for (int i = 0; i < COLS.length; i++) {
+      sb.append(COLS[i]);
+    }
+    return sb.toString(); 
+  }
+  
+  /**
+   * find the longest op name out of completed tasks.  
+   * @param taskStats completed tasks to be considered.
+   * @return the longest op name out of completed tasks.
+   */
+  protected String longestOp(Iterator taskStats) {
+    String longest = OP;
+    while (taskStats.hasNext()) {
+      TaskStats stat = (TaskStats) taskStats.next();
+      if (stat.getElapsed()>=0) { // consider only tasks that ended
+        String name = stat.getTask().getName();
+        if (name.length() > longest.length()) {
+          longest = name;
+        }
+      }
+    }
+    return longest;
+  }
+  
+  /**
+   * Compute a report line for the given task stat.
+   * @param longestOp size of longest op name in the table.
+   * @param stat task stat to be printed.
+   * @return the report line.
+   */
+  protected String taskReportLine(String longestOp, TaskStats stat) {
+    PerfTask task = stat.getTask();
+    StringBuffer sb = new StringBuffer();
+    sb.append(Format.format(task.getName(), longestOp));
+    String round = (stat.getRound()>=0 ? ""+stat.getRound() : "-");
+    sb.append(Format.formatPaddLeft(round, ROUND));
+    sb.append(getRunData().getConfig().getColsValuesForValsByRound(stat.getRound()));
+    sb.append(Format.format(stat.getNumRuns(), RUNCNT)); 
+    sb.append(Format.format(stat.getCount() / stat.getNumRuns(), RECCNT));
+    long elapsed = (stat.getElapsed()>0 ? stat.getElapsed() : 1); // assume at least 1ms
+    sb.append(Format.format(1,(float) (stat.getCount() * 1000.0 / elapsed), RECSEC));
+    sb.append(Format.format(2, (float) stat.getElapsed() / 1000, ELAPSED));
+    sb.append(Format.format(0, (float) stat.getMaxUsedMem() / stat.getNumRuns(), USEDMEM));

+    sb.append(Format.format(0, (float) stat.getMaxTotMem() / stat.getNumRuns(), TOTMEM));
+    return sb.toString();
+  }
+
+  protected Report genPartialReport(int reported, LinkedHashMap partOfTasks, int totalSize)
{
+    String longetOp = longestOp(partOfTasks.values().iterator());
+    boolean first = true;
+    StringBuffer sb = new StringBuffer();
+    sb.append(tableTitle(longetOp));
+    sb.append(newline);
+    int lineNum = 0;
+    for (Iterator it = partOfTasks.values().iterator(); it.hasNext();) {
+      TaskStats stat = (TaskStats) it.next();
+      if (!first) {
+        sb.append(newline);
+      }
+      first = false;
+      String line = taskReportLine(longetOp,stat);
+      lineNum++;
+      if (partOfTasks.size()>2 && lineNum%2==0) {
+        line = line.replaceAll("   "," - ");
+      }
+      sb.append(line);
+    }
+    String reptxt = (reported==0 ? "No Matching Entries Were Found!" : sb.toString());
+    return new Report(reptxt,partOfTasks.size(),reported,totalSize);
+  }
+
+
+
 }

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java
Wed Mar 21 06:52:34 2007
@@ -23,8 +23,8 @@
 
 /**
  * Reset all index and input data and call gc, erase index and dir, does NOT clear statistics.
- * This contains ResetInputs.
- * Other side effects: writers/readers nulified, deleted, closed.
+ * <br>This contains ResetInputs.
+ * <br>Other side effects: writers/readers nulified, deleted, closed.
  * Index is erased.
  * Directory is erased.
  */

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java
Wed Mar 21 06:52:34 2007
@@ -24,7 +24,7 @@
 /**
  * Reset all index and input data and call gc, does NOT erase index/dir, does NOT clear statistics.
  * This contains ResetInputs.
- * Other side effects: writers/readers nulified, closed.
+ * <br>Other side effects: writers/readers nulified, closed.
  * Index is NOT erased.
  * Directory is NOT erased.
  */

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTask.java
Wed Mar 21 06:52:34 2007
@@ -49,7 +49,7 @@
   }
 
   public QueryMaker getQueryMaker() {
-    return getRunData().getSearchQueryMaker();
+    return getRunData().getQueryMaker(this);
   }
 
 

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetTask.java
Wed Mar 21 06:52:34 2007
@@ -18,15 +18,16 @@
  */
 
 import org.apache.lucene.benchmark.byTask.PerfRunData;
-import org.apache.lucene.benchmark.byTask.feeds.QueryMaker;
 
 /**
  * Search and Travrese and Retrieve docs task.
  * 
  * <p>Note: This task reuses the reader if it is already open. 
  * Otherwise a reader is opened at start and closed at the end.
+ * 
+ * Takes optional param: traversal size (otherwise all results are traversed).
  */
-public class SearchTravRetTask extends ReadTask {
+public class SearchTravRetTask extends SearchTravTask {
 
   public SearchTravRetTask(PerfRunData runData) {
     super(runData);
@@ -35,22 +36,5 @@
   public boolean withRetrieve() {
     return true;
   }
-
-  public boolean withSearch() {
-    return true;
-  }
-
-  public boolean withTraverse() {
-    return true;
-  }
-
-  public boolean withWarm() {
-    return false;
-  }
-
-  public QueryMaker getQueryMaker() {
-    return getRunData().getSearchTravQueryMaker();
-  }
-
 
 }

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravTask.java
Wed Mar 21 06:52:34 2007
@@ -25,8 +25,12 @@
  * 
  * <p>Note: This task reuses the reader if it is already open. 
  * Otherwise a reader is opened at start and closed at the end.
+ * <p/>
+ * 
+ * Takes optional param: traversal size (otherwise all results are traversed).
  */
 public class SearchTravTask extends ReadTask {
+  protected int traversalSize = Integer.MAX_VALUE;
 
   public SearchTravTask(PerfRunData runData) {
     super(runData);
@@ -48,8 +52,25 @@
     return false;
   }
 
+  
+
   public QueryMaker getQueryMaker() {
-    return getRunData().getSearchTravRetQueryMaker();
+    return getRunData().getQueryMaker(this);
   }
 
+  public int traversalSize() {
+    return traversalSize;
+  }
+
+  public void setParams(String params) {
+    super.setParams(params);
+    traversalSize = (int)Float.parseFloat(params);
+  }
+
+  /* (non-Javadoc)
+   * @see org.apache.lucene.benchmark.byTask.tasks.PerfTask#supportsParams()
+   */
+  public boolean supportsParams() {
+    return true;
+  }
 }

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SetPropTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SetPropTask.java?view=diff&rev=520890&r1=520889&r2=520890
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SetPropTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SetPropTask.java
Wed Mar 21 06:52:34 2007
@@ -24,7 +24,8 @@
  * A property may have a single value, or a sequence of values, seprated by ":". 
  * If a sequence of values is specified, each time a new round starts, 
  * the next (cyclic) value is taken.  
- * Other side effects: none.
+ * <br>Other side effects: none.
+ * <br>Takes mandatory param: "name,value" pair. 
  * @see org.apache.lucene.benchmark.byTask.tasks.NewRoundTask
  */
 public class SetPropTask extends PerfTask {
@@ -55,4 +56,11 @@
     value = params.substring(k+1).trim();
   }
 
+  /* (non-Javadoc)
+   * @see org.apache.lucene.benchmark.byTask.tasks.PerfTask#supportsParams()
+   */
+  public boolean supportsParams() {
+    return true;
+  }
+
 }



Mime
View raw message