Skip to content

Commit

Permalink
Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Apr 5, 2018
1 parent 354abf0 commit 746cf77
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
22 changes: 18 additions & 4 deletions src/test/benchmarks/io/vertx/benchmarks/RunOnContextBenchmark.java
Expand Up @@ -14,6 +14,7 @@
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.impl.BenchmarkContext;
import io.vertx.core.impl.ContextTask;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Fork;
Expand All @@ -37,23 +38,36 @@ public static class BaselineState {
Vertx vertx;
BenchmarkContext context;
Handler<Void> task;
ContextTask ioTask;

@Setup
public void setup() {
vertx = Vertx.vertx();
context = BenchmarkContext.create(vertx);
task = v -> consume("the-string");
ioTask = () -> consume("the-string");
}
}

@Benchmark
public void baseline(BaselineState state) {
state.context.runDirect(state.task);
public void runOnContext(BaselineState state) {
state.context.runOnContext(state.task);
}

@Benchmark
@Fork(jvmArgsAppend = { "-Dvertx.threadChecks=false", "-Dvertx.disableContextTimings=true", "-Dvertx.disableTCCL=true" })
public void noChecks(BaselineState state) {
state.context.runDirect(state.task);
public void runOnContextNoChecks(BaselineState state) {
state.context.runOnContext(state.task);
}

@Benchmark
public void executeFromIO(BaselineState state) {
state.context.executeFromIO(state.ioTask);
}

@Benchmark
@Fork(jvmArgsAppend = { "-Dvertx.threadChecks=false", "-Dvertx.disableContextTimings=true", "-Dvertx.disableTCCL=true" })
public void executeFromIONoChecks(BaselineState state) {
state.context.executeFromIO(state.ioTask);
}
}
4 changes: 0 additions & 4 deletions src/test/benchmarks/io/vertx/core/impl/BenchmarkContext.java
Expand Up @@ -34,10 +34,6 @@ protected void executeAsync(Handler<Void> task) {
wrapTask(null, task, true, null).run();
}

public void runDirect(Handler<Void> task) {
wrapTask(null, task, true, null).run();
}

@Override
public boolean isEventLoopContext() {
return false;
Expand Down

0 comments on commit 746cf77

Please sign in to comment.