Beispiel #1
0
 private void writeGnuplotHeaderSingle(
     Writer w, String dirName, String fileName, String operation, AbstractMeter meter, String ds)
     throws IOException {
   writeGnuplotHeaderCommon(w, dirName, fileName, meter.getUnit());
   w.writeln("set title \"Benchmarking " + meter.getName() + " on " + ds + " " + operation + "\"");
   w.writeln(
       "plot '"
           + dirName
           + fileName
           + rawExtension
           + "' using 1:2 notitle with lp linetype 1, \"\" using 1:2:3:4 title '"
           + ds
           + "' with errorbars linetype 1");
 }
Beispiel #2
0
  private void writeResultForGnuplot(
      AbstractMeter meter, String ds, String operation, int size, Collection<Double> values)
      throws IOException {
    String dirName = outputDir + "/" + meter.getName() + "/";

    // Write data for *single* plot
    String fileName = ds + "_" + operation;
    String extension = plotExtension;
    Writer w = fileWriters.get(dirName + fileName + extension);
    if (w == null) {
      w = new Writer(dirName, fileName + extension);
      writeGnuplotHeaderSingle(w, dirName, fileName, operation, meter, ds);
      fileWriters.put(dirName + fileName + extension, w);
    }

    extension = rawExtension;
    w = fileWriters.get(dirName + fileName + extension);
    if (w == null) {
      w = new Writer(dirName, fileName + extension);
      fileWriters.put(dirName + fileName + extension, w);
    }

    double min = Collections.min(values);
    double max = Collections.max(values);
    double mean = DoubleMath.mean(values);

    w.writeln(" " + size + " " + mean + " " + min + " " + max);

    // Check for the aggregation file
    extension = plotExtension;
    String innerLastWrittenOp = lastWrittenOp.get(dirName + operation + extension);

    if (innerLastWrittenOp == null || !innerLastWrittenOp.equals(operation)) {
      w = fileWriters.get(dirName + aggregationFile);
      if (w == null) {
        w = new Writer(dirName, aggregationFile, true);
        fileWriters.put(dirName + aggregationFile, w);
      }
      w.writeln(operation + ";" + meter.getUnit() + ";" + fileName + rawExtension);
    }
    lastWrittenOp.put(dirName + operation + extension, operation);
  }
Beispiel #3
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();
      }
    }
  }