diff --git a/.gitignore b/.gitignore
index c8969adcb4..af65eb1319 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,5 @@ atlassian-ide-plugin.xml
sonar-project.properties
test-output/
*.pyc
+jmh-results.*
+dependency-reduced-pom.xml
diff --git a/modules/swagger-core/pom.xml b/modules/swagger-core/pom.xml
index 30e285f00f..3fb056a030 100644
--- a/modules/swagger-core/pom.xml
+++ b/modules/swagger-core/pom.xml
@@ -14,6 +14,91 @@
src/main/java
install
+
+ org.codehaus.mojo
+ exec-maven-plugin
+
+
+ run-benchmarks
+ integration-test
+
+ exec
+
+
+ test
+ java
+
+ -classpath
+
+ org.openjdk.jmh.Main
+ .*
+
+ -bm
+ avgt,thrpt
+
+ -f
+ 1
+
+ -tu
+ ms
+
+ -rff
+ jmh-results.csv
+
+ -o
+ jmh-results.txt
+
+ -foe
+ true
+
+
+
+
+ -wi
+ 1
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.3
+
+
+ package
+
+ shade
+
+
+ ${uberjar.name}
+
+
+ org.openjdk.jmh.Main
+
+
+
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+
+
+
biz.aQute.bnd
bnd-maven-plugin
@@ -52,6 +137,17 @@
+
+ org.openjdk.jmh
+ jmh-core
+ ${jmh.version}
+
+
+ org.openjdk.jmh
+ jmh-generator-annprocess
+ ${jmh.version}
+ provided
+
jakarta.xml.bind
jakarta.xml.bind-api
@@ -160,5 +256,6 @@
0.60
0.0
3
+ 1.37
diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java
index 6f32a71c09..0ef17d6a5c 100644
--- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java
+++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java
@@ -26,6 +26,7 @@
import io.swagger.v3.oas.models.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.testng.annotations.Test;
+import org.openjdk.jmh.annotations.*;
import java.io.IOException;
import java.util.HashSet;
@@ -41,6 +42,7 @@
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
+@State(Scope.Benchmark)
public class SpecFilterTest {
private static final String RESOURCE_RECURSIVE_MODELS = "specFiles/recursivemodels.json";
@@ -171,11 +173,21 @@ private void validateParameters(Operation operation) {
}
}
+ private OpenAPI openAPI;
+
+ @Setup(Level.Trial)
+ public void setUp() throws IOException {
+ // RK: Move I/O outside the benchmark to reduce variability.
+ openAPI = getOpenAPI(RESOURCE_PATH);
+ }
+
+ // @Param({"10", "100", "1000"})
+ @Param({"10"})
+ private int numThreads;
+
@Test(description = "it should clone everything concurrently")
+ @Benchmark
public void cloneEverythingConcurrent() throws IOException {
- int numThreads = 10;
- final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
-
ThreadGroup tg = new ThreadGroup("SpecFilterTest" + "|" + System.currentTimeMillis());
final Map filteredMap = new ConcurrentHashMap<>();
for (int i = 0; i < numThreads; i++) {
diff --git a/pom.xml b/pom.xml
index 6f7bd69a9d..957d9c6ba7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -664,5 +664,7 @@
0.5.0
UTF-8
https://oss.sonatype.org/content/repositories/snapshots/
+
+ true