changeset 1064:9686a533ffe6

7901219: Clean up raw types in harness and generated classes Contributed-by: Staffan Friberg <staffan.friberg@oracle.com>
author shade
date Thu, 18 Dec 2014 22:53:10 +0300
parents 9453f3e72b6e
children de75b9914a57
files jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/LogConsumeProfiler.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResultAggregator.java jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java jmh-core/src/main/java/org/openjdk/jmh/results/Aggregator.java jmh-core/src/main/java/org/openjdk/jmh/results/AverageTimeResult.java jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java jmh-core/src/main/java/org/openjdk/jmh/results/SingleShotResult.java jmh-core/src/main/java/org/openjdk/jmh/results/ThroughputResult.java
diffstat 11 files changed, 28 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/LogConsumeProfiler.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/LogConsumeProfiler.java	Thu Dec 18 22:53:10 2014 +0300
@@ -119,7 +119,7 @@
 
         public static class LogAggregator implements Aggregator<LogConsumeResult> {
             @Override
-            public Result aggregate(Collection<LogConsumeResult> results) {
+            public LogConsumeResult aggregate(Collection<LogConsumeResult> results) {
                 String label = null;
                 Collection<String> allLines = new ArrayList<String>();
                 for (LogConsumeResult r : results) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Thu Dec 18 22:53:10 2014 +0300
@@ -608,7 +608,7 @@
     }
 
     private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) {
-        writer.println(ident(1) + "public Collection<? extends Result> " + methodGroup.getName() + "_" + benchmarkKind +
+        writer.println(ident(1) + "public Collection<ThroughputResult> " + methodGroup.getName() + "_" + benchmarkKind +
                 "(InfraControl control, ThreadParams threadParams) throws Throwable {");
 
         methodProlog(writer, methodGroup);
@@ -674,7 +674,7 @@
             // iteration prolog
             iterationEpilog(writer, 3, method, states);
 
-            writer.println(ident(3) + "Collection<Result> results = new ArrayList<Result>();");
+            writer.println(ident(3) + "Collection<ThroughputResult> results = new ArrayList<ThroughputResult>();");
             writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getOperations(), res.getTime(), control.benchmarkParams.getTimeUnit()));");
             if (!isSingleMethod) {
                 writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.getOperations(), res.getTime(), control.benchmarkParams.getTimeUnit()));");
@@ -717,7 +717,7 @@
     }
 
     private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) {
-        writer.println(ident(1) + "public Collection<? extends Result> " + methodGroup.getName() + "_" + benchmarkKind +
+        writer.println(ident(1) + "public Collection<AverageTimeResult> " + methodGroup.getName() + "_" + benchmarkKind +
                 "(InfraControl control, ThreadParams threadParams) throws Throwable {");
 
         methodProlog(writer, methodGroup);
@@ -781,7 +781,7 @@
 
             iterationEpilog(writer, 3, method, states);
 
-            writer.println(ident(3) + "Collection<Result> results = new ArrayList<Result>();");
+            writer.println(ident(3) + "Collection<AverageTimeResult> results = new ArrayList<AverageTimeResult>();");
             writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getOperations(), res.getTime(), control.benchmarkParams.getTimeUnit()));");
             if (!isSingleMethod) {
                 writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.getOperations(), res.getTime(), control.benchmarkParams.getTimeUnit()));");
@@ -836,7 +836,7 @@
     }
 
     private void generateSampleTime(ClassInfo classInfo, PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) {
-        writer.println(ident(1) + "public Collection<? extends Result> " + methodGroup.getName() + "_" + benchmarkKind +
+        writer.println(ident(1) + "public Collection<SampleTimeResult> " + methodGroup.getName() + "_" + benchmarkKind +
                 "(InfraControl control, ThreadParams threadParams) throws Throwable {");
 
         methodProlog(writer, methodGroup);
@@ -898,7 +898,7 @@
 
             iterationEpilog(writer, 3, method, states);
 
-            writer.println(ident(3) + "Collection<Result> results = new ArrayList<Result>();");
+            writer.println(ident(3) + "Collection<SampleTimeResult> results = new ArrayList<SampleTimeResult>();");
             writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", buffer, control.benchmarkParams.getTimeUnit()));");
             if (!isSingleMethod) {
                 writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", buffer, control.benchmarkParams.getTimeUnit()));");
@@ -957,7 +957,7 @@
     }
 
     private void generateSingleShotTime(ClassInfo classInfo, PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) {
-        writer.println(ident(1) + "public Collection<? extends Result> " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {");
+        writer.println(ident(1) + "public Collection<SingleShotResult> " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {");
 
         methodProlog(writer, methodGroup);
 
@@ -985,7 +985,7 @@
 
             iterationEpilog(writer, 3, method, states);
 
-            writer.println(ident(3) + "Collection<Result> results = new ArrayList<Result>();");
+            writer.println(ident(3) + "Collection<SingleShotResult> results = new ArrayList<SingleShotResult>();");
             writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getTime(), control.benchmarkParams.getTimeUnit()));");
             if (!isSingleMethod) {
                 writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.getTime(), control.benchmarkParams.getTimeUnit()));");
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Thu Dec 18 22:53:10 2014 +0300
@@ -830,7 +830,7 @@
 
     static class PerfResultAggregator implements Aggregator<PerfResult> {
         @Override
-        public Result aggregate(Collection<PerfResult> results) {
+        public PerfResult aggregate(Collection<PerfResult> results) {
             String output = "";
             for (PerfResult r : results) {
                 output += r.output;
@@ -1094,4 +1094,4 @@
         }
     }
 
-}
\ No newline at end of file
+}
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java	Thu Dec 18 22:53:10 2014 +0300
@@ -214,7 +214,7 @@
     static class PerfResultAggregator implements Aggregator<PerfResult> {
 
         @Override
-        public Result aggregate(Collection<PerfResult> results) {
+        public PerfResult aggregate(Collection<PerfResult> results) {
             long cycles = 0;
             long instructions = 0;
             String output = "";
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResultAggregator.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResultAggregator.java	Thu Dec 18 22:53:10 2014 +0300
@@ -26,14 +26,13 @@
 
 import org.openjdk.jmh.results.AggregatorUtils;
 import org.openjdk.jmh.results.Aggregator;
-import org.openjdk.jmh.results.Result;
 import org.openjdk.jmh.util.ListStatistics;
 
 import java.util.Collection;
 
 public class ProfilerResultAggregator implements Aggregator<ProfilerResult> {
     @Override
-    public Result aggregate(Collection<ProfilerResult> results) {
+    public ProfilerResult aggregate(Collection<ProfilerResult> results) {
         ListStatistics stats = new ListStatistics();
         for (ProfilerResult r : results) {
             stats.addValue(r.getScore());
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java	Thu Dec 18 22:53:10 2014 +0300
@@ -318,7 +318,7 @@
 
     public static class StackResultAggregator implements Aggregator<StackResult> {
         @Override
-        public Result aggregate(Collection<StackResult> results) {
+        public StackResult aggregate(Collection<StackResult> results) {
             Map<Thread.State, Multiset<StackRecord>> sum = new EnumMap<Thread.State, Multiset<StackRecord>>(Thread.State.class);
             for (StackResult r : results) {
                 for (Map.Entry<Thread.State, Multiset<StackRecord>> entry : r.stacks.entrySet()) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/Aggregator.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/Aggregator.java	Thu Dec 18 22:53:10 2014 +0300
@@ -41,5 +41,5 @@
      * @param results results to aggregate
      * @return aggregated result; may throw exceptions on validation errors
      */
-    Result aggregate(Collection<R> results);
+    R aggregate(Collection<R> results);
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/AverageTimeResult.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/AverageTimeResult.java	Thu Dec 18 22:53:10 2014 +0300
@@ -34,7 +34,7 @@
 /**
  * Result class that stores average operation time.
  */
-public class AverageTimeResult extends Result {
+public class AverageTimeResult extends Result<AverageTimeResult> {
     private static final long serialVersionUID = 6937689337229703312L;
 
     public AverageTimeResult(ResultRole mode, String label, long operations, long durationNs, TimeUnit tu) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java	Thu Dec 18 22:53:10 2014 +0300
@@ -34,7 +34,7 @@
 /**
  * Result class that samples operation time.
  */
-public class SampleTimeResult extends Result {
+public class SampleTimeResult extends Result<SampleTimeResult> {
     private static final long serialVersionUID = -295298353763294757L;
 
     private final SampleBuffer buffer;
@@ -89,12 +89,12 @@
     }
 
     @Override
-    protected Aggregator getThreadAggregator() {
+    protected Aggregator<SampleTimeResult> getThreadAggregator() {
         return new JoiningAggregator();
     }
 
     @Override
-    protected Aggregator getIterationAggregator() {
+    protected Aggregator<SampleTimeResult> getIterationAggregator() {
         return new JoiningAggregator();
     }
 
@@ -105,7 +105,7 @@
     static class JoiningAggregator implements Aggregator<SampleTimeResult> {
 
         @Override
-        public Result aggregate(Collection<SampleTimeResult> results) {
+        public SampleTimeResult aggregate(Collection<SampleTimeResult> results) {
             SampleBuffer buffer = new SampleBuffer();
             TimeUnit tu = null;
             for (SampleTimeResult r : results) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/SingleShotResult.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/SingleShotResult.java	Thu Dec 18 22:53:10 2014 +0300
@@ -34,7 +34,7 @@
 /**
  * Result class that stores once operation execution time.
  */
-public class SingleShotResult extends Result {
+public class SingleShotResult extends Result<SingleShotResult> {
     private static final long serialVersionUID = -1251578870918524737L;
 
     public SingleShotResult(ResultRole role, String label, long duration, TimeUnit outputTimeUnit) {
@@ -53,12 +53,12 @@
     }
 
     @Override
-    protected Aggregator getThreadAggregator() {
+    protected Aggregator<SingleShotResult> getThreadAggregator() {
         return new AveragingAggregator();
     }
 
     @Override
-    protected Aggregator getIterationAggregator() {
+    protected Aggregator<SingleShotResult> getIterationAggregator() {
         return new AveragingAggregator();
     }
 
@@ -67,7 +67,7 @@
      */
     static class AveragingAggregator implements Aggregator<SingleShotResult> {
         @Override
-        public Result aggregate(Collection<SingleShotResult> results) {
+        public SingleShotResult aggregate(Collection<SingleShotResult> results) {
             ListStatistics stat = new ListStatistics();
             for (SingleShotResult r : results) {
                 stat.addValue(r.getScore());
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/ThroughputResult.java	Thu Dec 18 21:35:14 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/ThroughputResult.java	Thu Dec 18 22:53:10 2014 +0300
@@ -34,7 +34,7 @@
 /**
  * Result class that counts the number of operations performed during a specified unit of time.
  */
-public class ThroughputResult extends Result {
+public class ThroughputResult extends Result<ThroughputResult> {
     private static final long serialVersionUID = 7269598073169413322L;
 
     public ThroughputResult(ResultRole role, String label, long operations, long durationNs, TimeUnit outputTimeUnit) {
@@ -49,12 +49,12 @@
     }
 
     @Override
-    protected Aggregator getThreadAggregator() {
+    protected Aggregator<ThroughputResult> getThreadAggregator() {
         return new ThroughputAggregator(AggregationPolicy.SUM);
     }
 
     @Override
-    protected Aggregator getIterationAggregator() {
+    protected Aggregator<ThroughputResult> getIterationAggregator() {
         return new ThroughputAggregator(AggregationPolicy.AVG);
     }
 
@@ -66,7 +66,7 @@
         }
 
         @Override
-        public Result aggregate(Collection<ThroughputResult> results) {
+        public ThroughputResult aggregate(Collection<ThroughputResult> results) {
             ListStatistics stat = new ListStatistics();
             for (ThroughputResult r : results) {
                 stat.addValue(r.getScore());