Skip to content

Commit e680120

Browse files
committed
Fix benchmarks
1 parent 502c4c4 commit e680120

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

pom.xml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,13 +598,45 @@
598598
</build>
599599
</profile>
600600
<profile>
601+
<!-- mvn clean test -P benchmark -->
601602
<id>benchmark</id>
602603
<properties>
603604
<skipTests>true</skipTests>
604605
<benchmark>org.apache</benchmark>
605606
</properties>
607+
<dependencies>
608+
<dependency>
609+
<groupId>org.openjdk.jmh</groupId>
610+
<artifactId>jmh-core</artifactId>
611+
<version>${commons.jmh.version}</version>
612+
<scope>test</scope>
613+
</dependency>
614+
<dependency>
615+
<groupId>org.openjdk.jmh</groupId>
616+
<artifactId>jmh-generator-annprocess</artifactId>
617+
<version>${commons.jmh.version}</version>
618+
<scope>test</scope>
619+
</dependency>
620+
<dependency>
621+
<groupId>org.apache.commons</groupId>
622+
<artifactId>commons-collections4</artifactId>
623+
<version>4.5.0</version>
624+
<scope>test</scope>
625+
</dependency>
626+
</dependencies>
606627
<build>
607628
<plugins>
629+
<!-- Enable the compilation of the benchmarks -->
630+
<plugin>
631+
<artifactId>maven-compiler-plugin</artifactId>
632+
<version>${commons.compiler.version}</version>
633+
<configuration combine.self="override">
634+
<testIncludes>
635+
<testInclude>**/*</testInclude>
636+
</testIncludes>
637+
</configuration>
638+
</plugin>
639+
<!-- Hook the benchmarks to the test phase -->
608640
<plugin>
609641
<groupId>org.codehaus.mojo</groupId>
610642
<artifactId>exec-maven-plugin</artifactId>
@@ -620,12 +652,12 @@
620652
<executable>java</executable>
621653
<arguments>
622654
<argument>-classpath</argument>
623-
<classpath/>
655+
<classpath />
624656
<argument>org.openjdk.jmh.Main</argument>
625657
<argument>-rf</argument>
626658
<argument>json</argument>
627659
<argument>-rff</argument>
628-
<argument>target/jmh-result.${benchmark}.json</argument>
660+
<argument>target/jmh-result.json</argument>
629661
<argument>${benchmark}</argument>
630662
</arguments>
631663
</configuration>

src/test/java/org/apache/commons/text/jmh/LongestCommonSubsequencePerformance.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,31 +134,31 @@ public void setup() {
134134
}
135135

136136
@Benchmark
137-
void testLCS(final InputData data) {
137+
public void testLCS(final InputData data) {
138138
final LongestCommonSubsequence lcs = new LongestCommonSubsequence();
139139
for (final Pair<CharSequence, CharSequence> input : data.inputs) {
140140
lcs.longestCommonSubsequence(input.getLeft(), input.getRight());
141141
}
142142
}
143143

144144
@Benchmark
145-
void testLCSBaseline(final InputData data) {
145+
public void testLCSBaseline(final InputData data) {
146146
final BaselineLongestCommonSubsequence lcs = new BaselineLongestCommonSubsequence();
147147
for (final Pair<CharSequence, CharSequence> input : data.inputs) {
148148
lcs.longestCommonSubsequence(input.getLeft(), input.getRight());
149149
}
150150
}
151151

152152
@Benchmark
153-
void testLCSLen(final InputData data) {
153+
public void testLCSLen(final InputData data) {
154154
final LongestCommonSubsequence lcs = new LongestCommonSubsequence();
155155
for (final Pair<CharSequence, CharSequence> input : data.inputs) {
156156
lcs.apply(input.getLeft(), input.getRight());
157157
}
158158
}
159159

160160
@Benchmark
161-
void testLCSLenBaseline(final InputData data) {
161+
public void testLCSLenBaseline(final InputData data) {
162162
final BaselineLongestCommonSubsequence lcs = new BaselineLongestCommonSubsequence();
163163
for (final Pair<CharSequence, CharSequence> input : data.inputs) {
164164
lcs.apply(input.getLeft(), input.getRight());

0 commit comments

Comments
 (0)