Example #1
0
 @Override
 public int compare(MethodResult o1, MethodResult o2) {
   Object[] pso1 = o1.getInputParamSet();
   Object[] pso2 = o2.getInputParamSet();
   if (pso1[0] != pso2[0])
     return ((Class) pso1[0]).getSimpleName().compareTo(((Class) pso2[0]).getSimpleName());
   if ((int) pso1[1] > (int) pso2[1]) return +1;
   if ((int) pso1[1] < (int) pso2[1]) return -1;
   return 0;
 }
Example #2
0
  @Override
  public void visitBenchmark(BenchmarkResult res) {
    ArrayList<String> resultList = new ArrayList<String>();
    for (final AbstractMeter meter : res.getRegisteredMeters()) {
      for (final ClassResult classRes : res.getIncludedResults()) {
        ArrayList<MethodResult> methResults =
            new ArrayList<MethodResult>(classRes.getIncludedResults());

        Collections.sort(methResults, new BenchmarkingVisitor.MethResultComparator());

        for (final MethodResult methRes : methResults) {
          Object[] paramSet = methRes.getInputParamSet();
          Class<? extends IDataStructure> clazz = (Class<? extends IDataStructure>) paramSet[0];
          int inputSize = (int) paramSet[1];
          int operationSize = conf.getOperationSize(inputSize);

          double perElement = methRes.mean(meter) / operationSize;

          String methodName =
              ((BenchmarkMethod) methRes.getRelatedElement()).getMethodToBench().getName();
          String resString =
              meter.getName()
                  + "_"
                  + clazz.getSimpleName()
                  + "_"
                  + methodName
                  + ", size "
                  + String.format("%5d", inputSize)
                  + ": "
                  + methRes.mean(meter)
                  + ", per Element: "
                  + perElement;
          resultList.add(resString);
          try {
            Collection<Double> results = methRes.getResultSet(meter);

            Collection<Double> listWithoutMaxN =
                skipMaxElements(results, BenchmarkingConf.elementsToSkip);

            Collection<Double> resultsNormalized = new ArrayList<Double>(results.size() - 1);
            for (Double singleRes : listWithoutMaxN) {
              resultsNormalized.add(singleRes / operationSize);
            }

            String keyForEntry = "";
            switch (meter.getClass().getSimpleName()) {
              case "MemMeter":
                keyForEntry = "MEMORYBENCHMARK";
                break;
              case "TimeMeter":
                keyForEntry = "RUNTIMEBENCHMARK";
                break;
              default:
                throw new RuntimeException("Got unknown meter " + meter.getClass().getSimpleName());
            }
            keyForEntry += "_" + clazz.getSimpleName() + "_" + methodName;
            keyForEntry = keyForEntry.toUpperCase();

            BenchmarkingResult entry = this.getResultEntry(keyForEntry);
            resultsNormalized = entry.addToMap(inputSize, resultsNormalized);
            collectedMeasurementData.put(keyForEntry, entry);

            writeResultForGnuplot(
                meter, clazz.getSimpleName(), methodName, inputSize, resultsNormalized);
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    }
    Collections.sort(resultList);
    try {
      writeEntriesToProfilerFiles();
    } catch (IOException e2) {
      // TODO Auto-generated catch block
      e2.printStackTrace();
    }

    for (Entry<String, StringBuilder> e : fileWritersBufferData.entrySet()) {
      // Get the proper fileWriter
      Writer w = fileWriters.get(e.getKey());
      try {
        w.writeln(e.getValue().toString());
      } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
    }

    for (Entry<String, Writer> w : fileWriters.entrySet()) {
      try {
        w.getValue().close();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }