Cleanup unused code in BenchmarkGenerator
Christoph Dreis
christoph.dreis at freenet.de
Sat May 6 15:35:30 UTC 2017
Hey,
Just noticed some unused parameters in BenchmarkGenerator that we could
remove.
What do you think? Worth a patch?
Cheers,
Christoph
=========== PATCH ==============
diff --git
a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.
java
b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.
java
---
a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.
java
+++
b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.
java
@@ -81,7 +81,7 @@
validateBenchmark(clazz, clazzes.get(clazz));
Collection<BenchmarkInfo> infos =
makeBenchmarkInfo(clazz, clazzes.get(clazz));
for (BenchmarkInfo info : infos) {
- generateClass(source, destination, clazz, info);
+ generateClass(destination, clazz, info);
}
benchmarkInfos.addAll(infos);
} catch (GenerationException ge) {
@@ -436,7 +436,7 @@
/**
* Create and generate Java code for a class and it's methods
*/
- private void generateClass(GeneratorSource source, GeneratorDestination
destination, ClassInfo classInfo, BenchmarkInfo info) throws IOException {
+ private void generateClass(GeneratorDestination destination, ClassInfo
classInfo, BenchmarkInfo info) throws IOException {
StateObjectHandler states = new
StateObjectHandler(compilerControl);
// bind all methods
@@ -469,7 +469,7 @@
// write all methods
for (Mode benchmarkKind : Mode.values()) {
if (benchmarkKind == Mode.All) continue;
- generateMethod(classInfo, benchmarkKind, writer,
info.methodGroup, states);
+ generateMethod(benchmarkKind, writer, info.methodGroup,
states);
}
// Write out state initializers
@@ -520,31 +520,31 @@
/**
* Generate the method for a specific benchmark method
*/
- private void generateMethod(ClassInfo classInfo, Mode benchmarkKind,
PrintWriter writer, MethodGroup methodGroup, StateObjectHandler states) {
+ private void generateMethod(Mode benchmarkKind, PrintWriter writer,
MethodGroup methodGroup, StateObjectHandler states) {
writer.println();
switch (benchmarkKind) {
case Throughput:
- generateThroughput(classInfo, writer, benchmarkKind,
methodGroup, states);
+ generateThroughput(writer, benchmarkKind, methodGroup,
states);
break;
case AverageTime:
- generateAverageTime(classInfo, writer, benchmarkKind,
methodGroup, states);
+ generateAverageTime(writer, benchmarkKind, methodGroup,
states);
break;
case SampleTime:
- generateSampleTime(classInfo, writer, benchmarkKind,
methodGroup, states);
+ generateSampleTime(writer, benchmarkKind, methodGroup,
states);
break;
case SingleShotTime:
- generateSingleShotTime(classInfo, writer, benchmarkKind,
methodGroup, states);
+ generateSingleShotTime(writer, benchmarkKind, methodGroup,
states);
break;
default:
throw new AssertionError("Shouldn't be here");
}
}
- private void generateThroughput(ClassInfo classInfo, PrintWriter
writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler
states) {
+ private void generateThroughput(PrintWriter writer, Mode benchmarkKind,
MethodGroup methodGroup, StateObjectHandler states) {
writer.println(ident(1) + "public BenchmarkTaskResult " +
methodGroup.getName() + "_" + benchmarkKind +
"(InfraControl control, ThreadParams threadParams) throws
Throwable {");
- methodProlog(writer, methodGroup);
+ methodProlog(writer);
boolean isSingleMethod = (methodGroup.methods().size() == 1);
int subGroup = -1;
@@ -633,7 +633,7 @@
writer.println(ident(3) + "results.add(" + res + ");");
}
- methodEpilog(writer, methodGroup);
+ methodEpilog(writer);
writer.println(ident(3) + "return results;");
writer.println(ident(2) + "} else");
@@ -676,11 +676,11 @@
}
}
- private void generateAverageTime(ClassInfo classInfo, PrintWriter
writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler
states) {
+ private void generateAverageTime(PrintWriter writer, Mode
benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) {
writer.println(ident(1) + "public BenchmarkTaskResult " +
methodGroup.getName() + "_" + benchmarkKind +
"(InfraControl control, ThreadParams threadParams) throws
Throwable {");
- methodProlog(writer, methodGroup);
+ methodProlog(writer);
boolean isSingleMethod = (methodGroup.methods().size() == 1);
int subGroup = -1;
@@ -765,7 +765,7 @@
}
addAuxCounters(writer, "AverageTimeResult", states, method);
- methodEpilog(writer, methodGroup);
+ methodEpilog(writer);
writer.println(ident(3) + "return results;");
writer.println(ident(2) + "} else");
@@ -811,8 +811,7 @@
"Blackhole blackhole, Control notifyControl, int
startRndMask";
}
- private void methodProlog(PrintWriter writer, MethodGroup methodGroup)
{
- // do nothing
+ private void methodProlog(PrintWriter writer) {
writer.println(ident(2) + "this.benchmarkParams =
control.benchmarkParams;");
writer.println(ident(2) + "this.iterationParams =
control.iterationParams;");
writer.println(ident(2) + "this.threadParams = threadParams;");
@@ -822,7 +821,7 @@
writer.println(ident(2) + "}");
}
- private void methodEpilog(PrintWriter writer, MethodGroup methodGroup)
{
+ private void methodEpilog(PrintWriter writer) {
writer.println(ident(3) + "this.blackhole.evaporate(\"Yes, I am
Stephen Hawking, and know a thing or two about black holes.\");");
}
@@ -834,11 +833,11 @@
}
}
- private void generateSampleTime(ClassInfo classInfo, PrintWriter
writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler
states) {
+ private void generateSampleTime(PrintWriter writer, Mode benchmarkKind,
MethodGroup methodGroup, StateObjectHandler states) {
writer.println(ident(1) + "public BenchmarkTaskResult " +
methodGroup.getName() + "_" + benchmarkKind +
"(InfraControl control, ThreadParams threadParams) throws
Throwable {");
- methodProlog(writer, methodGroup);
+ methodProlog(writer);
boolean isSingleMethod = (methodGroup.methods().size() == 1);
int subGroup = -1;
@@ -920,7 +919,7 @@
writer.println(ident(3) + "results.add(new
SampleTimeResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\",
buffer, benchmarkParams.getTimeUnit()));");
writer.println(ident(3) + "results.add(new
SampleTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", buffer,
benchmarkParams.getTimeUnit()));");
}
- methodEpilog(writer, methodGroup);
+ methodEpilog(writer);
writer.println(ident(3) + "return results;");
writer.println(ident(2) + "} else");
@@ -981,10 +980,10 @@
}
}
- private void generateSingleShotTime(ClassInfo classInfo, PrintWriter
writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler
states) {
+ private void generateSingleShotTime(PrintWriter writer, Mode
benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) {
writer.println(ident(1) + "public BenchmarkTaskResult " +
methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control,
ThreadParams threadParams) throws Throwable {");
- methodProlog(writer, methodGroup);
+ methodProlog(writer);
boolean isSingleMethod = (methodGroup.methods().size() == 1);
int subGroup = -1;
@@ -1027,7 +1026,7 @@
writer.println(ident(3) + "results.add(new
SingleShotResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\",
res.getTime(), benchmarkParams.getTimeUnit()));");
writer.println(ident(3) + "results.add(new
SingleShotResult(ResultRole.SECONDARY, \"" + method.getName() + "\",
res.getTime(), benchmarkParams.getTimeUnit()));");
}
- methodEpilog(writer, methodGroup);
+ methodEpilog(writer);
writer.println(ident(3) + "return results;");
writer.println(ident(2) + "} else");
More information about the jmh-dev
mailing list