specializing jvmArgs in a derived class

Aleksey Shipilev aleksey.shipilev at oracle.com
Fri Aug 22 20:12:09 UTC 2014


On 08/23/2014 12:05 AM, Deneau, Tom wrote:
> I see your point about making @Benchmark be in the derived classes.
> I only did it the other way because 90% of the time, it doesn't need to be overridden with anything.
> But perhaps some restructuring would be better...

Understood. Well, since the JMH parameters are resolved through the
inheritance hierarchy [1], it might be fruitful to just introduce the
intermediary class, a la:

 @Fork(jvmArgs = ...)
 class MyCustomSharedSettings {
 }

 class OverridenSettingsBenchmark extends MyCustomSharedSettings {
    @Benchmark
    public void bench() {
    }
 }

 class JustABenchmark {
    @Benchmark
    public void bench() {
    }
 }

Thanks,
-Aleksey.

[1]
http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_24_Inheritance.java



More information about the jmh-dev mailing list