FileDocCategorySizeDatePackage
ReportTask.javaAPI DocApache Lucene 2.2.05690Sat Jun 16 22:20:58 BST 2007org.apache.lucene.benchmark.byTask.tasks

ReportTask

public abstract class ReportTask extends PerfTask
Report (abstract) task - all report tasks extend this task.

Fields Summary
protected static final String
newline
protected static final String
OP
Get a textual summary of the benchmark results, average from all test runs.
protected static final String
ROUND
protected static final String
RUNCNT
protected static final String
RECCNT
protected static final String
RECSEC
protected static final String
ELAPSED
protected static final String
USEDMEM
protected static final String
TOTMEM
protected static final String[]
COLS
Constructors Summary
public ReportTask(org.apache.lucene.benchmark.byTask.PerfRunData runData)

    super(runData);
  
Methods Summary
protected org.apache.lucene.benchmark.byTask.stats.ReportgenPartialReport(int reported, java.util.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);
  
protected java.lang.StringlongestOp(java.util.Iterator taskStats)
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.

    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;
  
protected booleanshouldNeverLogAtStart()

    return true;
  
protected booleanshouldNotRecordStats()

    return true;
  
protected java.lang.StringtableTitle(java.lang.String longestOp)
Compute a title line for a report table

param
longestOp size of longest op name in the table
return
the table title line.


                            
       
    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(); 
  
protected java.lang.StringtaskReportLine(java.lang.String longestOp, org.apache.lucene.benchmark.byTask.stats.TaskStats stat)
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.

    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();