예제 #1
0
 void render(
     PerformanceTestHistory testHistory,
     Transformer<String, MeasuredOperationList> valueRenderer,
     PrintWriter out) {
   List<? extends PerformanceTestExecution> sortedResults =
       Lists.reverse(testHistory.getExecutions());
   out.println("  [");
   List<String> labels = testHistory.getScenarioLabels();
   for (int i = 0; i < labels.size(); i++) {
     if (i > 0) {
       out.println(",");
     }
     out.println("  {");
     out.println("    \"label\": \"" + labels.get(i) + "\",");
     out.print("\"data\": [");
     boolean empty = true;
     for (int j = 0; j < sortedResults.size(); j++) {
       PerformanceTestExecution results = sortedResults.get(j);
       MeasuredOperationList measuredOperations = results.getScenarios().get(i);
       if (!measuredOperations.isEmpty()) {
         if (!empty) {
           out.print(", ");
         }
         out.print("[" + j + ", " + valueRenderer.transform(measuredOperations) + "]");
         empty = false;
       }
     }
     out.println("]");
     out.print("  }");
   }
   out.println();
   out.println("]");
 }
예제 #2
0
 @Override
 public void render(PerformanceTestHistory testHistory, Writer output) throws IOException {
   PrintWriter out = new PrintWriter(output);
   List<? extends PerformanceTestExecution> sortedResults =
       Lists.reverse(testHistory.getExecutions());
   out.println("{");
   out.println("\"executionLabels\": [");
   for (int i = 0; i < sortedResults.size(); i++) {
     PerformanceTestExecution results = sortedResults.get(i);
     if (i > 0) {
       out.println(", ");
     }
     out.print("{");
     out.print("\"id\": \"" + results.getExecutionId() + "\"");
     out.print(", \"branch\":\"" + results.getVcsBranch() + "\"");
     out.print(", \"date\":\"" + format.date(new Date(results.getStartTime())) + "\"");
     out.print(", \"commits\":[\"");
     out.print(Joiner.on("\",\"").join(results.getVcsCommits()));
     out.print("\"]");
     out.print("}");
   }
   out.println("],");
   out.print("\"totalTime\":");
   render(
       testHistory,
       new Transformer<String, MeasuredOperationList>() {
         public String transform(MeasuredOperationList original) {
           return format.seconds(original.getTotalTime().getAverage());
         }
       },
       out);
   out.println(",");
   out.print("\"configurationTime\":");
   render(
       testHistory,
       new Transformer<String, MeasuredOperationList>() {
         public String transform(MeasuredOperationList original) {
           return format.seconds(original.getConfigurationTime().getAverage());
         }
       },
       out);
   out.println(",");
   out.print("\"executionTime\":");
   render(
       testHistory,
       new Transformer<String, MeasuredOperationList>() {
         public String transform(MeasuredOperationList original) {
           return format.seconds(original.getExecutionTime().getAverage());
         }
       },
       out);
   out.println(",");
   out.print("\"compileTotalTime\":");
   render(
       testHistory,
       new Transformer<String, MeasuredOperationList>() {
         public String transform(MeasuredOperationList original) {
           return format.seconds(original.getCompileTotalTime().getAverage());
         }
       },
       out);
   out.println(",");
   out.print("\"gcTotalTime\":");
   render(
       testHistory,
       new Transformer<String, MeasuredOperationList>() {
         public String transform(MeasuredOperationList original) {
           return format.seconds(original.getGcTotalTime().getAverage());
         }
       },
       out);
   out.println(",");
   out.print("\"miscTime\":");
   render(
       testHistory,
       new Transformer<String, MeasuredOperationList>() {
         public String transform(MeasuredOperationList original) {
           Amount<Duration> miscTime =
               original
                   .getTotalTime()
                   .getAverage()
                   .minus(original.getConfigurationTime().getAverage())
                   .minus(original.getExecutionTime().getAverage());
           return format.seconds(miscTime);
         }
       },
       out);
   out.println(",");
   out.print("\"heapUsage\":");
   render(
       testHistory,
       new Transformer<String, MeasuredOperationList>() {
         public String transform(MeasuredOperationList original) {
           return format.megabytes(original.getTotalMemoryUsed().getAverage());
         }
       },
       out);
   out.println("}");
   out.flush();
 }