Skip to content

Commit 18c432c

Browse files
committed
benchmarks: simplify way to run benchmarks
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
1 parent bc9e812 commit 18c432c

File tree

3 files changed

+50
-40
lines changed

3 files changed

+50
-40
lines changed

oncrpc4j-benchmark/pom.xml

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,6 @@
1212
<artifactId>oncrpc4j-benchmarks</artifactId>
1313
<packaging>jar</packaging>
1414

15-
<profiles>
16-
<profile>
17-
<id>benchmark</id>
18-
<build>
19-
<plugins>
20-
<plugin>
21-
<groupId>org.codehaus.mojo</groupId>
22-
<artifactId>exec-maven-plugin</artifactId>
23-
<executions>
24-
<execution>
25-
<goals>
26-
<goal>exec</goal>
27-
</goals>
28-
<phase>integration-test</phase>
29-
</execution>
30-
</executions>
31-
<configuration>
32-
<executable>java</executable>
33-
<classpathScope>test</classpathScope>
34-
<arguments>
35-
<argument>-classpath</argument>
36-
<classpath />
37-
<argument>org.dcache.oncrpc4j.benchmarks.BenchmarkRunner</argument>
38-
<argument>.*</argument>
39-
</arguments>
40-
</configuration>
41-
</plugin>
42-
</plugins>
43-
</build>
44-
</profile>
45-
</profiles>
46-
4715
<!--
4816
EXTERNAL DEPENDENCIES
4917
-->
@@ -75,7 +43,53 @@
7543
<artifactId>oncrpc4j-core</artifactId>
7644
<version>${project.version}</version>
7745
</dependency>
46+
<dependency>
47+
<groupId>org.slf4j</groupId>
48+
<artifactId>slf4j-nop</artifactId>
49+
<version>1.7.36</version>
50+
</dependency>
7851

7952
</dependencies>
8053

54+
<build>
55+
<plugins>
56+
<plugin>
57+
<groupId>org.apache.maven.plugins</groupId>
58+
<artifactId>maven-shade-plugin</artifactId>
59+
<version>3.3.0</version>
60+
<executions>
61+
<execution>
62+
<phase>package</phase>
63+
<goals>
64+
<goal>shade</goal>
65+
</goals>
66+
<configuration>
67+
<transformers>
68+
<transformer
69+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
70+
<mainClass>org.openjdk.jmh.Main</mainClass>
71+
</transformer>
72+
<transformer
73+
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
74+
</transformers>
75+
<filters>
76+
<filter>
77+
<!--
78+
Shading signed JARs will fail without this.
79+
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
80+
-->
81+
<artifact>*:*</artifact>
82+
<excludes>
83+
<exclude>META-INF/*.SF</exclude>
84+
<exclude>META-INF/*.DSA</exclude>
85+
<exclude>META-INF/*.RSA</exclude>
86+
</excludes>
87+
</filter>
88+
</filters>
89+
</configuration>
90+
</execution>
91+
</executions>
92+
</plugin>
93+
</plugins>
94+
</build>
8195
</project>
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.dcache.oncrpc4j.benchmarks;
22

3+
import java.io.IOException;
34
import org.openjdk.jmh.results.format.ResultFormatType;
45
import org.openjdk.jmh.runner.Runner;
56
import org.openjdk.jmh.runner.RunnerException;
@@ -12,12 +13,7 @@
1213
*/
1314
public class BenchmarkRunner {
1415

15-
public static void main(String[] args) throws RunnerException {
16-
Options opt = new OptionsBuilder()
17-
.include(TlsOverhead.class.getSimpleName())
18-
.resultFormat(ResultFormatType.JSON)
19-
.build();
20-
21-
new Runner(opt).run();
16+
public static void main(String[] args) throws RunnerException, IOException {
17+
org.openjdk.jmh.Main.main(args);
2218
}
2319
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<junit.version>4.13.1</junit.version>
7878
<mockito-core.version>3.6.0</mockito-core.version>
7979
<logback-classic.version>1.2.3</logback-classic.version>
80-
<jmh.version>1.21</jmh.version>
80+
<jmh.version>1.35</jmh.version>
8181
</properties>
8282

8383

0 commit comments

Comments
 (0)