Skip to content

Commit 5558949

Browse files
committed
Add a Maven benchmark profile for JMH
1 parent 1c8915d commit 5558949

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

pom.xml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@
8383
<version>33.5.0-jre</version>
8484
<scope>test</scope>
8585
</dependency>
86+
<dependency>
87+
<groupId>org.openjdk.jmh</groupId>
88+
<artifactId>jmh-core</artifactId>
89+
<version>${commons.jmh.version}</version>
90+
<scope>test</scope>
91+
</dependency>
8692
</dependencies>
8793
<distributionManagement>
8894
<site>
@@ -365,6 +371,70 @@
365371
</pluginRepository>
366372
</pluginRepositories>
367373
</profile>
374+
<!-- Profile to build and run the benchmarks. Use 'mvn test -Pbenchmark', and add '-Dbenchmark=foo' to run only the foo benchmark -->
375+
<profile>
376+
<id>benchmark</id>
377+
<properties>
378+
<skipTests>true</skipTests>
379+
<benchmark>org.apache</benchmark>
380+
</properties>
381+
<dependencies>
382+
<dependency>
383+
<groupId>org.openjdk.jmh</groupId>
384+
<artifactId>jmh-core</artifactId>
385+
<version>${commons.jmh.version}</version>
386+
<scope>test</scope>
387+
</dependency>
388+
<dependency>
389+
<groupId>org.openjdk.jmh</groupId>
390+
<artifactId>jmh-generator-annprocess</artifactId>
391+
<version>${commons.jmh.version}</version>
392+
<scope>test</scope>
393+
</dependency>
394+
</dependencies>
395+
<build>
396+
<plugins>
397+
<!-- Enable the compilation of the benchmarks -->
398+
<plugin>
399+
<artifactId>maven-compiler-plugin</artifactId>
400+
<version>${commons.compiler.version}</version>
401+
<configuration combine.self="override">
402+
<testIncludes>
403+
<testInclude>**/*</testInclude>
404+
</testIncludes>
405+
</configuration>
406+
</plugin>
407+
<!-- Hook the benchmarks to the test phase -->
408+
<plugin>
409+
<groupId>org.codehaus.mojo</groupId>
410+
<artifactId>exec-maven-plugin</artifactId>
411+
<executions>
412+
<execution>
413+
<id>benchmark</id>
414+
<phase>test</phase>
415+
<goals>
416+
<goal>exec</goal>
417+
</goals>
418+
<configuration>
419+
<classpathScope>test</classpathScope>
420+
<executable>java</executable>
421+
<arguments>
422+
<argument>-classpath</argument>
423+
<classpath />
424+
<argument>org.openjdk.jmh.Main</argument>
425+
<argument>-rf</argument>
426+
<argument>json</argument>
427+
<argument>-rff</argument>
428+
<argument>target/jmh-result.json</argument>
429+
<argument>${benchmark}</argument>
430+
</arguments>
431+
</configuration>
432+
</execution>
433+
</executions>
434+
</plugin>
435+
</plugins>
436+
</build>
437+
</profile>
368438
</profiles>
369439
<developers>
370440
<developer>

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Apache RAT plugin console warnings.</action>
4444
<!-- ADD -->
4545
<action type="add" dev="ggregory" due-to="Gary Gregory">Add generics to UnmodifiableIterator for the wrapped type.</action>
46+
<action type="add" dev="ggregory" due-to="Gary Gregory">Add a Maven benchmark profile for JMH.</action>
4647
<!-- UPDATE -->
4748
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-parent from 81 to 93 #612, #645, #662, #663.</action>
4849
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump com.google.guava:guava-testlib from 33.3.1-jre to 33.5.0-jre #644.</action>

0 commit comments

Comments
 (0)