Skip to content

Commit

Permalink
Fix JMH benchmark and update JMH version
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Jun 26, 2017
1 parent f3dcd13 commit 84883bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -61,7 +61,7 @@
<stack.version>3.5.0-SNAPSHOT</stack.version> <stack.version>3.5.0-SNAPSHOT</stack.version>
<jetty.alpnAgent.version>2.0.6</jetty.alpnAgent.version> <jetty.alpnAgent.version>2.0.6</jetty.alpnAgent.version>
<jetty.alpnAgent.path>${settings.localRepository}/org/mortbay/jetty/alpn/jetty-alpn-agent/${jetty.alpnAgent.version}/jetty-alpn-agent-${jetty.alpnAgent.version}.jar</jetty.alpnAgent.path> <jetty.alpnAgent.path>${settings.localRepository}/org/mortbay/jetty/alpn/jetty-alpn-agent/${jetty.alpnAgent.version}/jetty-alpn-agent-${jetty.alpnAgent.version}.jar</jetty.alpnAgent.path>
<jmh.version>1.17.3</jmh.version> <jmh.version>1.19</jmh.version>


</properties> </properties>


Expand Down
2 changes: 1 addition & 1 deletion src/test/benchmarks/io/vertx/benchmarks/BenchmarkBase.java
Expand Up @@ -32,7 +32,7 @@
@Measurement(iterations = 10, time = 2, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 10, time = 2, timeUnit = TimeUnit.SECONDS)
@Threads(1) @Threads(1)
@BenchmarkMode(Mode.Throughput) @BenchmarkMode(Mode.Throughput)
@Fork(value = 1, jvmArgsAppend = { @Fork(value = 1, jvmArgs = {
"-XX:+UseBiasedLocking", "-XX:+UseBiasedLocking",
"-XX:BiasedLockingStartupDelay=0", "-XX:BiasedLockingStartupDelay=0",
"-XX:+AggressiveOpts", "-XX:+AggressiveOpts",
Expand Down
19 changes: 7 additions & 12 deletions src/test/benchmarks/io/vertx/benchmarks/HttpServerBenchmark.java
Expand Up @@ -65,10 +65,13 @@
@Threads(16) @Threads(16)
public class HttpServerBenchmark extends BenchmarkBase { public class HttpServerBenchmark extends BenchmarkBase {


private static final ByteBuf GET = Unpooled.unreleasableBuffer(Unpooled.copiedBuffer((
"GET / HTTP/1.1\r\n" +
"\r\n").getBytes()));

VertxInternal vertx; VertxInternal vertx;
EmbeddedChannel vertxChannel; EmbeddedChannel vertxChannel;
EmbeddedChannel nettyChannel; EmbeddedChannel nettyChannel;
ByteBuf GET;


private static final CharSequence RESPONSE_TYPE_PLAIN = io.vertx.core.http.HttpHeaders.createOptimized("text/plain"); private static final CharSequence RESPONSE_TYPE_PLAIN = io.vertx.core.http.HttpHeaders.createOptimized("text/plain");


Expand Down Expand Up @@ -111,9 +114,6 @@ public void setup() {
HandlerHolder<HttpHandlers> holder = new HandlerHolder<>(context, new HttpHandlers(app, null, null)); HandlerHolder<HttpHandlers> holder = new HandlerHolder<>(context, new HttpHandlers(app, null, null));
ServerHandler handler = new ServerHandler(null, new HttpServerOptions(), "localhost", holder, null); ServerHandler handler = new ServerHandler(null, new HttpServerOptions(), "localhost", holder, null);
vertxChannel.pipeline().addLast("handler", handler); vertxChannel.pipeline().addLast("handler", handler);
GET = Unpooled.unreleasableBuffer(Unpooled.copiedBuffer((
"GET / HTTP/1.1\r\n" +
"\r\n").getBytes()));


nettyChannel = new EmbeddedChannel(new HttpRequestDecoder( nettyChannel = new EmbeddedChannel(new HttpRequestDecoder(
options.getMaxInitialLineLength(), options.getMaxInitialLineLength(),
Expand Down Expand Up @@ -164,31 +164,26 @@ private void writeResponse(ChannelHandlerContext ctx, HttpRequest request, ByteB
@Benchmark @Benchmark
public void vertx(Blackhole blackhole) { public void vertx(Blackhole blackhole) {
vertxChannel.writeInbound(GET); vertxChannel.writeInbound(GET);
Object result = vertxChannel.outboundMessages().poll(); ByteBuf result = (ByteBuf) vertxChannel.outboundMessages().poll();
blackhole.consume(result); blackhole.consume(result);
} }


@Fork(value = 1, jvmArgsAppend = { @Fork(value = 1, jvmArgsAppend = {
"-XX:+UseBiasedLocking",
"-XX:BiasedLockingStartupDelay=0",
"-Dvertx.threadChecks=false", "-Dvertx.threadChecks=false",
"-Dvertx.disableContextTimings=true", "-Dvertx.disableContextTimings=true",
"-Dvertx.disableTCCL=true ", "-Dvertx.disableTCCL=true ",
"-XX:+AggressiveOpts",
"-Djmh.executor=CUSTOM",
"-Djmh.executor.class=io.vertx.core.impl.VertxExecutorService"
}) })
@Benchmark @Benchmark
public void vertxOpt(Blackhole blackhole) { public void vertxOpt(Blackhole blackhole) {
vertxChannel.writeInbound(GET); vertxChannel.writeInbound(GET);
Object result = vertxChannel.outboundMessages().poll(); ByteBuf result = (ByteBuf) vertxChannel.outboundMessages().poll();
blackhole.consume(result); blackhole.consume(result);
} }


@Benchmark @Benchmark
public void netty(Blackhole blackhole) { public void netty(Blackhole blackhole) {
nettyChannel.writeInbound(GET); nettyChannel.writeInbound(GET);
Object result = nettyChannel.outboundMessages().poll(); ByteBuf result = (ByteBuf) nettyChannel.outboundMessages().poll();
blackhole.consume(result); blackhole.consume(result);
} }
} }

0 comments on commit 84883bb

Please sign in to comment.