Skip to content

Commit

Permalink
Merge pull request Netflix#1035 from mattrjacobs/rename-jmh-tests
Browse files Browse the repository at this point in the history
Rename JMH tests for easier execution by regex
  • Loading branch information
mattrjacobs committed Jan 4, 2016
2 parents 517813d + c460a5e commit 0bdf123
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 214 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import java.util.concurrent.TimeUnit;

public class MultiThreadedMetricsTest {
public class CommandExecutionAndConcurrentMetricsReadPerfTest {
@State(Scope.Thread)
public static class CommandState {
HystrixCommand<Integer> command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.infra.Blackhole;
import rx.Observable;
import rx.schedulers.Schedulers;

Expand All @@ -41,38 +42,52 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class CommandSetterExecutionPerfTest {
public class CommandExecutionPerfTest {

static HystrixCommandProperties.Setter threadIsolatedCommandDefaults = HystrixCommandProperties.Setter()
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD)
.withRequestCacheEnabled(true)
.withRequestLogEnabled(true)
.withCircuitBreakerEnabled(true)
.withCircuitBreakerForceOpen(false);

static HystrixCommandProperties.Setter semaphoreIsolatedCommandDefaults = HystrixCommandProperties.Setter()
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)
.withRequestCacheEnabled(true)
.withRequestLogEnabled(true)
.withCircuitBreakerEnabled(true)
.withCircuitBreakerForceOpen(false);

static HystrixThreadPoolProperties.Setter threadPoolDefaults = HystrixThreadPoolProperties.Setter()
.withCoreSize(100);

private static HystrixCommandProperties.Setter getCommandSetter(HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy) {
switch (isolationStrategy) {
case THREAD: return threadIsolatedCommandDefaults;
default: return semaphoreIsolatedCommandDefaults;
}
}

@State(Scope.Thread)
public static class CommandState {
HystrixCommand<Integer> command;

@Param({"true", "false"})
public boolean forceCircuitOpen;

@Param({"THREAD", "SEMAPHORE"})
public HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy;

@Param({"1", "100", "10000"})
public int blackholeConsumption;

@Setup(Level.Invocation)
public void setUp() {
command = new HystrixCommand<Integer>(
HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("PERF"))
.andCommandPropertiesDefaults(
HystrixCommandProperties.Setter()
.withExecutionIsolationStrategy(isolationStrategy)
.withRequestCacheEnabled(true)
.withRequestLogEnabled(true)
.withCircuitBreakerEnabled(true)
.withCircuitBreakerForceOpen(forceCircuitOpen)
)
.andThreadPoolPropertiesDefaults(
HystrixThreadPoolProperties.Setter()
.withCoreSize(100)
)
.andCommandPropertiesDefaults(getCommandSetter(isolationStrategy))
.andThreadPoolPropertiesDefaults(threadPoolDefaults)
) {
@Override
protected Integer run() throws Exception {
Blackhole.consumeCPU(blackholeConsumption);
return 1;
}

Expand Down

This file was deleted.

0 comments on commit 0bdf123

Please sign in to comment.