Skip to content

Commit

Permalink
benchmarks: simplify way to run benchmarks
Browse files Browse the repository at this point in the history
Motivation:
JMH provided a wide mechanisms to control benchmark execution. However
we have lost it due to using custom runner.

Modification:
Use jmh runner to make use of full tool set of JMH.

Result:
more flexible benchmarking.

Acked-by: Lea Morschel
Target: master
  • Loading branch information
kofemann committed Jul 5, 2022
1 parent bc9e812 commit 18c432c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 40 deletions.
78 changes: 46 additions & 32 deletions oncrpc4j-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,6 @@
<artifactId>oncrpc4j-benchmarks</artifactId>
<packaging>jar</packaging>

<profiles>
<profile>
<id>benchmark</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
<phase>integration-test</phase>
</execution>
</executions>
<configuration>
<executable>java</executable>
<classpathScope>test</classpathScope>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>org.dcache.oncrpc4j.benchmarks.BenchmarkRunner</argument>
<argument>.*</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<!--
EXTERNAL DEPENDENCIES
-->
Expand Down Expand Up @@ -75,7 +43,53 @@
<artifactId>oncrpc4j-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.36</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<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.ServicesResourceTransformer"/>
</transformers>
<filters>
<filter>
<!--
Shading signed JARs will fail without this.
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
-->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.dcache.oncrpc4j.benchmarks;

import java.io.IOException;
import org.openjdk.jmh.results.format.ResultFormatType;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
Expand All @@ -12,12 +13,7 @@
*/
public class BenchmarkRunner {

public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(TlsOverhead.class.getSimpleName())
.resultFormat(ResultFormatType.JSON)
.build();

new Runner(opt).run();
public static void main(String[] args) throws RunnerException, IOException {
org.openjdk.jmh.Main.main(args);
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<junit.version>4.13.1</junit.version>
<mockito-core.version>3.6.0</mockito-core.version>
<logback-classic.version>1.2.3</logback-classic.version>
<jmh.version>1.21</jmh.version>
<jmh.version>1.35</jmh.version>
</properties>


Expand Down

0 comments on commit 18c432c

Please sign in to comment.