Skip to content

Commit 58c8f06

Browse files
Align Logging Backends JMH benchmarks with Servlet JMH
All JMH benchmarks now align in the profile benchmark. They can be executed with mvn verify -P benchmark Signed-off-by: Karsten Schnitter <k.schnitter@sap.com>
1 parent e151126 commit 58c8f06

File tree

8 files changed

+116
-2
lines changed

8 files changed

+116
-2
lines changed

cf-java-logging-support-log4j2/pom.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@
4848
</dependencies>
4949
<build>
5050
<plugins>
51+
<plugin>
52+
<groupId>org.codehaus.mojo</groupId>
53+
<artifactId>build-helper-maven-plugin</artifactId>
54+
<version>${build-helper-maven-plugin.version}</version>
55+
<executions>
56+
<execution>
57+
<id>add-jmh-sources</id>
58+
<phase>generate-test-sources</phase>
59+
<goals>
60+
<goal>add-test-source</goal>
61+
</goals>
62+
<configuration>
63+
<sources>
64+
<source>src/jmh/java</source>
65+
</sources>
66+
</configuration>
67+
</execution>
68+
</executions>
69+
</plugin>
5170
<plugin>
5271
<groupId>org.apache.maven.plugins</groupId>
5372
<artifactId>maven-compiler-plugin</artifactId>
@@ -72,6 +91,7 @@
7291
<plugin>
7392
<groupId>org.apache.maven.plugins</groupId>
7493
<artifactId>maven-surefire-plugin</artifactId>
94+
<version>${surefire.plugin.version}</version>
7595
<configuration>
7696
<systemPropertyVariables>
7797
<log.generate.application.logging.custom.fields>true
@@ -81,4 +101,38 @@
81101
</plugin>
82102
</plugins>
83103
</build>
104+
105+
<profiles>
106+
<profile>
107+
<id>benchmark</id>
108+
<build>
109+
<plugins>
110+
<plugin>
111+
<groupId>org.codehaus.mojo</groupId>
112+
<artifactId>exec-maven-plugin</artifactId>
113+
<version>${exec.plugin.version}</version>
114+
<executions>
115+
<execution>
116+
<id>run-benchmarks</id>
117+
<phase>verify</phase>
118+
<goals>
119+
<goal>exec</goal>
120+
</goals>
121+
<configuration>
122+
<executable>${java.home}/bin/java</executable>
123+
<classpathScope>test</classpathScope>
124+
<arguments>
125+
<argument>-classpath</argument>
126+
<classpath/>
127+
<argument>com.sap.hcp.cf.log4j2.benchmark.BenchmarkRunner</argument>
128+
</arguments>
129+
</configuration>
130+
</execution>
131+
</executions>
132+
</plugin>
133+
</plugins>
134+
</build>
135+
</profile>
136+
</profiles>
137+
84138
</project>

cf-java-logging-support-log4j2/src/test/java/com/sap/hcp/cf/log4j2/benchmark/BenchmarkRunner.java renamed to cf-java-logging-support-log4j2/src/jmh/java/com/sap/hcp/cf/log4j2/benchmark/BenchmarkRunner.java

File renamed without changes.

cf-java-logging-support-log4j2/src/test/java/com/sap/hcp/cf/log4j2/benchmark/EncodingBenchmarks.java renamed to cf-java-logging-support-log4j2/src/jmh/java/com/sap/hcp/cf/log4j2/benchmark/EncodingBenchmarks.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
import static com.sap.hcp.cf.logging.common.request.RequestRecordBuilder.requestRecord;
1717

18+
@BenchmarkMode(Mode.AverageTime)
19+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
1820
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
19-
@Measurement(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS)
21+
@Measurement(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
22+
@Fork(1)
2023
public class EncodingBenchmarks {
2124

2225
public static Logger LOG = LoggerFactory.getLogger(EncodingBenchmarks.class);

cf-java-logging-support-logback/pom.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,29 @@
3535
</dependencies>
3636
<build>
3737
<plugins>
38+
<plugin>
39+
<groupId>org.codehaus.mojo</groupId>
40+
<artifactId>build-helper-maven-plugin</artifactId>
41+
<version>${build-helper-maven-plugin.version}</version>
42+
<executions>
43+
<execution>
44+
<id>add-jmh-sources</id>
45+
<phase>generate-test-sources</phase>
46+
<goals>
47+
<goal>add-test-source</goal>
48+
</goals>
49+
<configuration>
50+
<sources>
51+
<source>src/jmh/java</source>
52+
</sources>
53+
</configuration>
54+
</execution>
55+
</executions>
56+
</plugin>
3857
<plugin>
3958
<groupId>org.apache.maven.plugins</groupId>
4059
<artifactId>maven-surefire-plugin</artifactId>
60+
<version>${surefire.plugin.version}</version>
4161
<configuration>
4262
<systemPropertyVariables>
4363
<log.generate.application.logging.custom.fields>true
@@ -47,4 +67,38 @@
4767
</plugin>
4868
</plugins>
4969
</build>
70+
71+
<profiles>
72+
<profile>
73+
<id>benchmark</id>
74+
<build>
75+
<plugins>
76+
<plugin>
77+
<groupId>org.codehaus.mojo</groupId>
78+
<artifactId>exec-maven-plugin</artifactId>
79+
<version>${exec.plugin.version}</version>
80+
<executions>
81+
<execution>
82+
<id>run-benchmarks</id>
83+
<phase>verify</phase>
84+
<goals>
85+
<goal>exec</goal>
86+
</goals>
87+
<configuration>
88+
<executable>${java.home}/bin/java</executable>
89+
<classpathScope>test</classpathScope>
90+
<arguments>
91+
<argument>-classpath</argument>
92+
<classpath/>
93+
<argument>com.sap.hcp.cf.logback.benchmark.BenchmarkRunner</argument>
94+
</arguments>
95+
</configuration>
96+
</execution>
97+
</executions>
98+
</plugin>
99+
</plugins>
100+
</build>
101+
</profile>
102+
</profiles>
103+
50104
</project>

cf-java-logging-support-logback/src/test/java/com/sap/hcp/cf/logback/benchmark/BenchmarkRunner.java renamed to cf-java-logging-support-logback/src/jmh/java/com/sap/hcp/cf/logback/benchmark/BenchmarkRunner.java

File renamed without changes.

cf-java-logging-support-logback/src/test/java/com/sap/hcp/cf/logback/benchmark/EncodingBenchmarks.java renamed to cf-java-logging-support-logback/src/jmh/java/com/sap/hcp/cf/logback/benchmark/EncodingBenchmarks.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
import static com.sap.hcp.cf.logging.common.request.RequestRecordBuilder.requestRecord;
1717

18+
@BenchmarkMode(Mode.AverageTime)
19+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
1820
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
1921
@Measurement(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
22+
@Fork(1)
2023
public class EncodingBenchmarks {
2124

2225
public static Logger LOG = LoggerFactory.getLogger(EncodingBenchmarks.class);

cf-java-logging-support-servlet/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
<properties>
1717
<maven-dependency-plugin.version>3.5.0</maven-dependency-plugin.version>
18-
<build-helper-maven-plugin.version>3.3.0</build-helper-maven-plugin.version>
1918
<maven-antrun-plugin.version>3.1.0</maven-antrun-plugin.version>
2019
</properties>
2120

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
<jar.plugin.version>3.5.0</jar.plugin.version>
9393
<surefire.plugin.version>3.5.3</surefire.plugin.version>
9494
<exec.plugin.version>3.6.3</exec.plugin.version>
95+
<build-helper-maven-plugin.version>3.3.0</build-helper-maven-plugin.version>
9596
<javadoc.plugin.version>3.12.0</javadoc.plugin.version>
9697
<gpg.plugin.version>3.2.8</gpg.plugin.version>
9798
<sonatype.plugin.version>0.10.0</sonatype.plugin.version>

0 commit comments

Comments
 (0)