Skip to content

Commit

Permalink
Add JMH annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
bgprudhomme committed Feb 20, 2024
1 parent 2c6170a commit 6872c45
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ atlassian-ide-plugin.xml
sonar-project.properties
test-output/
*.pyc
jmh-results.*
94 changes: 94 additions & 0 deletions modules/swagger-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,93 @@
<artifactId>swagger-core</artifactId>
<name>swagger-core</name>
<description>swagger-core</description>
<properties>
<jmh.version>1.37</jmh.version>
</properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>run-benchmarks</id>
<phase>integration-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>.*</argument>
<argument>-bm</argument>
<argument>avgt</argument>
<argument>-f</argument>
<argument>1</argument>
<argument>-tu</argument>
<argument>ms</argument>
<argument>-rff</argument>
<argument>jmh-results.csv</argument>
<argument>-o</argument>
<argument>jmh-results.txt</argument>
<!-- Only one iteration for now. -->
<argument>-i</argument>
<argument>1</argument>
<!-- Fail on error. -->
<argument>-foe</argument>
<argument>true</argument>
<!-- No warmup for now. -->
<argument>-wi</argument>
<argument>0</argument>
<!-- Do a batch warmup. -->
<argument>-wm</argument>
<argument>BULK</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${uberjar.name}</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<!--
Shading signed JARs will fail without this.
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
-->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
Expand Down Expand Up @@ -52,6 +135,17 @@
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -172,6 +174,7 @@ private void validateParameters(Operation operation) {
}

@Test(description = "it should clone everything concurrently")
@Benchmark
public void cloneEverythingConcurrent() throws IOException {
int numThreads = 10;
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
Expand Down

0 comments on commit 6872c45

Please sign in to comment.