This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git


The following commit(s) were added to refs/heads/master by this push:
     new 555894976 Add a Maven benchmark profile for JMH
555894976 is described below

commit 555894976701d77bdab8140c4d9fd2a853ed7b5b
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Dec 5 07:08:24 2025 -0500

    Add a Maven benchmark profile for JMH
---
 pom.xml                 | 70 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/changes/changes.xml |  1 +
 2 files changed, 71 insertions(+)

diff --git a/pom.xml b/pom.xml
index e086a89f9..c51e26167 100644
--- a/pom.xml
+++ b/pom.xml
@@ -83,6 +83,12 @@
       <version>33.5.0-jre</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.openjdk.jmh</groupId>
+      <artifactId>jmh-core</artifactId>
+      <version>${commons.jmh.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <distributionManagement>
     <site>
@@ -365,6 +371,70 @@
         </pluginRepository>
       </pluginRepositories>
     </profile>
+    <!-- Profile to build and run the benchmarks. Use 'mvn test -Pbenchmark', 
and add '-Dbenchmark=foo' to run only the foo benchmark -->
+    <profile>
+      <id>benchmark</id>
+      <properties>
+        <skipTests>true</skipTests>
+        <benchmark>org.apache</benchmark>
+      </properties>
+      <dependencies>
+        <dependency>
+          <groupId>org.openjdk.jmh</groupId>
+          <artifactId>jmh-core</artifactId>
+          <version>${commons.jmh.version}</version>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>org.openjdk.jmh</groupId>
+          <artifactId>jmh-generator-annprocess</artifactId>
+          <version>${commons.jmh.version}</version>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+      <build>
+        <plugins>
+          <!-- Enable the compilation of the benchmarks -->
+          <plugin>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <version>${commons.compiler.version}</version>
+            <configuration combine.self="override">
+              <testIncludes>
+                <testInclude>**/*</testInclude>
+              </testIncludes>
+            </configuration>
+          </plugin>
+          <!-- Hook the benchmarks to the test phase -->
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>benchmark</id>
+                <phase>test</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <classpathScope>test</classpathScope>
+                  <executable>java</executable>
+                  <arguments>
+                    <argument>-classpath</argument>
+                    <classpath />
+                    <argument>org.openjdk.jmh.Main</argument>
+                    <argument>-rf</argument>
+                    <argument>json</argument>
+                    <argument>-rff</argument>
+                    <argument>target/jmh-result.json</argument>
+                    <argument>${benchmark}</argument>
+                  </arguments>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
   </profiles>
   <developers>
     <developer>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 40fdb9c29..01f289224 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -43,6 +43,7 @@
     <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Apache RAT 
plugin console warnings.</action>
     <!-- ADD -->
     <action type="add" dev="ggregory" due-to="Gary Gregory">Add generics to 
UnmodifiableIterator for the wrapped type.</action>
+    <action type="add" dev="ggregory" due-to="Gary Gregory">Add a Maven 
benchmark profile for JMH.</action>
     <!-- UPDATE -->
     <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>
     <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>

Reply via email to