Exemplo n.º 1
0
 /**
  * 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(Iterable<TaskStats> taskStats) {
   String longest = OP;
   for (final TaskStats stat : taskStats) {
     if (stat.getElapsed() >= 0) { // consider only tasks that ended
       String name = stat.getTask().getName();
       if (name.length() > longest.length()) {
         longest = name;
       }
     }
   }
   return longest;
 }
Exemplo n.º 2
0
  protected Report genPartialReport(
      int reported, LinkedHashMap<String, TaskStats> partOfTasks, int totalSize) {
    String longetOp = longestOp(partOfTasks.values());
    boolean first = true;
    StringBuilder sb = new StringBuilder();
    sb.append(tableTitle(longetOp));
    sb.append(newline);
    int lineNum = 0;
    for (final TaskStats stat : partOfTasks.values()) {
      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);
      int[] byTime = stat.getCountsByTime();
      if (byTime != null) {
        sb.append(newline);
        int end = -1;
        for (int i = byTime.length - 1; i >= 0; i--) {
          if (byTime[i] != 0) {
            end = i;
            break;
          }
        }
        if (end != -1) {
          sb.append("  by time:");
          for (int i = 0; i < end; i++) {
            sb.append(' ').append(byTime[i]);
          }
        }
      }
    }

    String reptxt = (reported == 0 ? "No Matching Entries Were Found!" : sb.toString());
    return new Report(reptxt, partOfTasks.size(), reported, totalSize);
  }
Exemplo n.º 3
0
 /**
  * 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();
   StringBuilder sb = new StringBuilder();
   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(2, (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();
 }