Skip to content

Commit f3fb77f

Browse files
Louis RyanScottmitch
authored andcommitted
Have microbenchmarks produce a deployable artifact. Fix some minor miscellaneous issues.
Motivation: Allows for running benchmarks from built jars which is useful in development environments that only take released artifacts. Modifications: Move benchmarks into 'main' from 'test' Add @State annotations to benchmarks that are missing them Fix timing issue grabbing context during channel initialization Result: Users can run benchmarks more easily.
1 parent e48e6e4 commit f3fb77f

26 files changed

Lines changed: 227 additions & 27 deletions

microbench/pom.xml

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,17 @@
6464
<artifactId>netty-codec-http2</artifactId>
6565
<version>${project.version}</version>
6666
</dependency>
67-
<dependency>
68-
<groupId>${project.groupId}</groupId>
69-
<artifactId>netty-transport-native-epoll</artifactId>
70-
<version>${project.version}</version>
71-
<classifier>linux-${epoll.arch}</classifier>
72-
</dependency>
67+
<dependency>
68+
<groupId>${project.groupId}</groupId>
69+
<artifactId>netty-transport-native-epoll</artifactId>
70+
<version>${project.version}</version>
71+
<classifier>linux-${epoll.arch}</classifier>
72+
</dependency>
73+
<dependency>
74+
<groupId>junit</groupId>
75+
<artifactId>junit</artifactId>
76+
<scope>compile</scope>
77+
</dependency>
7378
<dependency>
7479
<groupId>org.openjdk.jmh</groupId>
7580
<artifactId>jmh-core</artifactId>
@@ -90,25 +95,49 @@
9095

9196
<build>
9297
<plugins>
93-
<plugin>
94-
<artifactId>maven-deploy-plugin</artifactId>
95-
<configuration>
96-
<skip>true</skip>
97-
</configuration>
98-
</plugin>
9998
<plugin>
10099
<groupId>org.apache.maven.plugins</groupId>
101100
<artifactId>maven-surefire-plugin</artifactId>
102101
<configuration>
102+
<testSourceDirectory>${project.build.sourceDirectory}</testSourceDirectory>
103+
<testClassesDirectory>${project.build.outputDirectory}</testClassesDirectory>
103104
<excludes>
104105
<exclude>**/AbstractMicrobenchmark.java</exclude>
105106
<exclude>**/*$*.class</exclude>
107+
<exclude>**/generated/*.class</exclude>
106108
</excludes>
107-
<systemPropertyVariables>
108-
<perfReportDir>${project.build.directory}/reports/performance/</perfReportDir>
109-
</systemPropertyVariables>
109+
<systemPropertyVariables>
110+
<perfReportDir>${project.build.directory}/reports/performance/</perfReportDir>
111+
</systemPropertyVariables>
110112
</configuration>
111113
</plugin>
114+
<plugin>
115+
<groupId>org.apache.felix</groupId>
116+
<artifactId>maven-bundle-plugin</artifactId>
117+
<executions>
118+
<execution>
119+
<id>generate-manifest</id>
120+
<phase>process-classes</phase>
121+
<goals>
122+
<goal>manifest</goal>
123+
</goals>
124+
<configuration>
125+
<supportedProjectTypes>
126+
<supportedProjectType>jar</supportedProjectType>
127+
<supportedProjectType>bundle</supportedProjectType>
128+
</supportedProjectTypes>
129+
<instructions>
130+
<Export-Package>${project.groupId}.*</Export-Package>
131+
<Export-Package>!*.generated.*</Export-Package>
132+
<!-- enforce JVM vendor package as optional -->
133+
<Import-Package>sun.nio.ch;resolution:=optional,org.eclipse.jetty.npn;version="[1,2)";resolution:=optional,org.eclipse.jetty.alpn;version="[1,2)";resolution:=optional,*</Import-Package>
134+
<!-- override "internal" private package convention -->
135+
<Private-Package>!*</Private-Package>
136+
</instructions>
137+
</configuration>
138+
</execution>
139+
</executions>
140+
</plugin>
112141
</plugins>
113142
<extensions>
114143
<extension>

microbench/src/test/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java renamed to microbench/src/main/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@
2222
import io.netty.microbench.util.AbstractMicrobenchmark;
2323
import org.openjdk.jmh.annotations.Benchmark;
2424
import org.openjdk.jmh.annotations.Param;
25+
import org.openjdk.jmh.annotations.Scope;
26+
import org.openjdk.jmh.annotations.State;
2527

2628
import java.util.Random;
2729

2830
/**
2931
* This class benchmarks different allocators with different allocation sizes.
3032
*/
33+
@State(Scope.Benchmark)
3134
public class ByteBufAllocatorBenchmark extends AbstractMicrobenchmark {
3235

3336
private static final ByteBufAllocator unpooledAllocator = new UnpooledByteBufAllocator(true);

microbench/src/test/java/io/netty/microbench/buffer/ByteBufUtilBenchmark.java renamed to microbench/src/main/java/io/netty/microbench/buffer/ByteBufUtilBenchmark.java

File renamed without changes.

microbench/src/test/java/io/netty/microbench/buffer/SwappedByteBufBenchmark.java renamed to microbench/src/main/java/io/netty/microbench/buffer/SwappedByteBufBenchmark.java

File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2015 The Netty Project
3+
*
4+
* The Netty Project licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
/**
17+
* Benchmarks for {@link io.netty.buffer}.
18+
*/
19+
package io.netty.microbench.buffer;

microbench/src/test/java/io/netty/microbench/channel/EmbeddedChannelWriteReleaseHandlerContext.java renamed to microbench/src/main/java/io/netty/microbench/channel/EmbeddedChannelWriteReleaseHandlerContext.java

File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2015 The Netty Project
3+
*
4+
* The Netty Project licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
/**
17+
* Benchmarks for {@link io.netty.channel}.
18+
*/
19+
package io.netty.microbench.channel;

microbench/src/test/java/io/netty/microbench/concurrent/FastThreadLocalBenchmark.java renamed to microbench/src/main/java/io/netty/microbench/concurrent/FastThreadLocalBenchmark.java

File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2015 The Netty Project
3+
*
4+
* The Netty Project licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
/**
17+
* Benchmarks for {@link io.netty.util.concurrent}.
18+
*/
19+
package io.netty.microbench.concurrent;

microbench/src/test/java/io/netty/microbench/http/HttpRequestDecoderBenchmark.java renamed to microbench/src/main/java/io/netty/microbench/http/HttpRequestDecoderBenchmark.java

File renamed without changes.

0 commit comments

Comments
 (0)