Running JMH Runner from inside the source code?

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Feb 3 02:33:51 PST 2014


On 02/03/2014 02:26 PM, Behrooz N wrote:
> Please find the output log here:
> https://gist.github.com/nobeh/15d2a3ccdbfc5ae75659

Thanks.

It seems like JMH is not aware about AppMicroBenchmark whatsoever, and
instead seems to know about JMH Samples only. I wonder if the
microbenchmark list from jmh-samples JAR just overrides the one
generated for your project.

Is there a reason you depend on jmh-samples? The dependency on jmh-core
should be enough. If you indeed need the dependency on jmh-samples, then
you should merge the microbenchmark lists, like e.g. by adding the
relevant <transformer> to maven-shade-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>1.5</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <finalName>microbenchmarks</finalName>
                <transformers>
                    <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>org.openjdk.jmh.Main</mainClass>
                    </transformer>
                    <transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/MicroBenchmarks</resource>
                    </transformer>
                </transformers>
            </configuration>
        </execution>
    </executions>
</plugin>


-Aleksey.


More information about the jmh-dev mailing list