You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by wi...@apache.org on 2018/11/29 00:24:47 UTC

[geode-benchmarks] branch develop updated: GEODE-6086: Change RunAnalyzer to return result object.

This is an automated email from the ASF dual-hosted git repository.

wirebaron pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git


The following commit(s) were added to refs/heads/develop by this push:
     new a0e70b7  GEODE-6086: Change RunAnalyzer to return result object.
a0e70b7 is described below

commit a0e70b7587b5cfab66aecc28330a17780266687d
Author: Brian Rowe <br...@pivotal.io>
AuthorDate: Wed Nov 28 16:18:40 2018 -0800

    GEODE-6086: Change RunAnalyzer to return result object.
    
    Rather than dumping the run results to a passed in writer, the
    BenchmarkRunAnalyzer now returns a serializable object containing the results.
    The writing of the results has been moved to a method on this object.
---
 .../apache/geode/perftest/analysis/Analyzer.java   |  2 +-
 .../perftest/analysis/BenchmarkRunAnalyzer.java    | 43 ++++++-------
 .../perftest/analysis/BenchmarkRunResult.java      | 71 ++++++++++++++++++++++
 .../analysis/BenchmarkRunAnalyzerTest.java         |  2 +-
 4 files changed, 93 insertions(+), 25 deletions(-)

diff --git a/harness/src/main/java/org/apache/geode/perftest/analysis/Analyzer.java b/harness/src/main/java/org/apache/geode/perftest/analysis/Analyzer.java
index b87f1f8..49272a3 100644
--- a/harness/src/main/java/org/apache/geode/perftest/analysis/Analyzer.java
+++ b/harness/src/main/java/org/apache/geode/perftest/analysis/Analyzer.java
@@ -59,6 +59,6 @@ public class Analyzer {
     analyzer.addProbe(new YardstickPercentileSensorParser());
     analyzer.addProbe(new YardstickHdrHistogramParser());
 
-    analyzer.analyzeTestRun(testResultDir, baselineResultDir, new PrintWriter(System.out));
+    analyzer.analyzeTestRun(testResultDir, baselineResultDir).writeResult(new PrintWriter(System.out));
   }
 }
diff --git a/harness/src/main/java/org/apache/geode/perftest/analysis/BenchmarkRunAnalyzer.java b/harness/src/main/java/org/apache/geode/perftest/analysis/BenchmarkRunAnalyzer.java
index 9a32e53..bda8fdc 100644
--- a/harness/src/main/java/org/apache/geode/perftest/analysis/BenchmarkRunAnalyzer.java
+++ b/harness/src/main/java/org/apache/geode/perftest/analysis/BenchmarkRunAnalyzer.java
@@ -16,8 +16,6 @@ package org.apache.geode.perftest.analysis;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Writer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -56,38 +54,37 @@ public class BenchmarkRunAnalyzer {
     probes.add(probeResultParser);
   }
 
-  public void analyzeTestRun(File testResultDir, File baselineResultDir, Writer output)
+  public BenchmarkRunResult analyzeTestRun(File testResultDir, File baselineResultDir)
       throws IOException {
     List<File> benchmarkDirs = Arrays.asList(testResultDir.listFiles());
+    BenchmarkRunResult result = new BenchmarkRunResult();
 
-    PrintWriter stream = new PrintWriter(output);
     for (File testDir : benchmarkDirs) {
-      final List<File> yardstickOutputDirsForTest = getYardstickOutputForBenchmarkDir(testDir);
-      if (yardstickOutputDirsForTest.isEmpty()) {
+      final List<File> testYardstickDirs = getYardstickOutputForBenchmarkDir(testDir);
+      if (testYardstickDirs.isEmpty()) {
         continue;
       }
       File baselineDir = new File(baselineResultDir, testDir.getName());
-      stream.println("-- " + testDir.getName() + " --");
+      final List<File> baselineYardstickDirs = getYardstickOutputForBenchmarkDir(baselineDir);
+
+      final BenchmarkRunResult.BenchmarkResult benchmarkResult = result.addBenchmark(testDir.getName());
       for (ProbeResultParser probe : probes) {
-        stream.println(probe.getResultDescription());
-        probe.reset();
-        for (File outputDirectory : yardstickOutputDirsForTest) {
-          probe.parseResults(outputDirectory);
-        }
-        double testResult = probe.getProbeResult();
-        stream.println("Result: " + String.valueOf(testResult));
-        probe.reset();
-        for (File outputDirectory : getYardstickOutputForBenchmarkDir(baselineDir)) {
-          probe.parseResults(outputDirectory);
-        }
-        double baselineResult = probe.getProbeResult();
-        stream.println("Baseline: " + String.valueOf(baselineResult));
-        stream.println("Relative performance: " + String.valueOf(testResult / baselineResult));
-        stream.println();
+        double testResult = getTestResult(testYardstickDirs, probe);
+        double baselineResult = getTestResult(baselineYardstickDirs, probe);
+
+        benchmarkResult.addProbeResult(probe.getResultDescription(), baselineResult, testResult);
       }
     }
 
-    stream.flush();
+    return result;
+  }
+
+  private double getTestResult(List<File> resultDirs, ProbeResultParser probe) throws IOException {
+    probe.reset();
+    for (File outputDirectory : resultDirs) {
+      probe.parseResults(outputDirectory);
+    }
+    return probe.getProbeResult();
   }
 
   private List<File> getYardstickOutputForBenchmarkDir(File benchmarkDir) throws IOException {
diff --git a/harness/src/main/java/org/apache/geode/perftest/analysis/BenchmarkRunResult.java b/harness/src/main/java/org/apache/geode/perftest/analysis/BenchmarkRunResult.java
new file mode 100644
index 0000000..43e0ff8
--- /dev/null
+++ b/harness/src/main/java/org/apache/geode/perftest/analysis/BenchmarkRunResult.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.perftest.analysis;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+public class BenchmarkRunResult implements Serializable {
+  private List<BenchmarkResult> benchmarkResults = new ArrayList<>();
+
+  public BenchmarkResult addBenchmark(String name) {
+    final BenchmarkResult benchmarkResult = new BenchmarkResult(name);
+    benchmarkResults.add(benchmarkResult);
+    return benchmarkResult;
+  }
+
+  public void writeResult(Writer output) {
+    PrintWriter stream = new PrintWriter(output);
+    for (BenchmarkResult benchmarkResult : benchmarkResults) {
+      stream.println("-- " + benchmarkResult.name + " --");
+      for (ProbeResult probeResult : benchmarkResult.probeResults) {
+        stream.println(probeResult.description);
+        stream.println("Result: " + String.valueOf(probeResult.test));
+        stream.println("Baseline: " + String.valueOf(probeResult.baseline));
+        stream.println(
+            "Relative performance: " + String.valueOf(probeResult.test / probeResult.baseline));
+        stream.println();
+      }
+    }
+  }
+
+  static class BenchmarkResult implements Serializable {
+    private final String name;
+    private final List<ProbeResult> probeResults = new ArrayList<>();
+
+    public BenchmarkResult(String name) {
+      this.name = name;
+    }
+
+    public void addProbeResult(String name, double baseline, double test) {
+      probeResults.add(new ProbeResult(name, baseline, test));
+    }
+  }
+
+  private static class ProbeResult implements Serializable {
+    private final String description;
+    private final double baseline;
+    private final double test;
+
+    public ProbeResult(String description, double baseline, double test) {
+      this.description = description;
+      this.baseline = baseline;
+      this.test = test;
+    }
+  }
+}
diff --git a/harness/src/test/java/org/apache/geode/perftest/analysis/BenchmarkRunAnalyzerTest.java b/harness/src/test/java/org/apache/geode/perftest/analysis/BenchmarkRunAnalyzerTest.java
index e838733..570399d 100644
--- a/harness/src/test/java/org/apache/geode/perftest/analysis/BenchmarkRunAnalyzerTest.java
+++ b/harness/src/test/java/org/apache/geode/perftest/analysis/BenchmarkRunAnalyzerTest.java
@@ -77,7 +77,7 @@ public class BenchmarkRunAnalyzerTest {
     ByteArrayOutputStream outputStream = new ByteArrayOutputStream(4000);
     StringWriter writer = new StringWriter();
 
-    harvester.analyzeTestRun(testFolder, baseFolder, writer);
+    harvester.analyzeTestRun(testFolder, baseFolder).writeResult(writer);
     System.out.println(writer.toString());
     BufferedReader resultReader = new BufferedReader(new StringReader(writer.toString()));