use of org.openjdk.jmh.annotations.Setup in project grpc-java by grpc.
the class UnaryCallQpsBenchmark method setup.
/**
* Setup with direct executors, small payloads and a large flow control window.
*/
@Setup(Level.Trial)
public void setup() throws Exception {
super.setup(ExecutorType.DIRECT, ExecutorType.DIRECT, MessageSize.SMALL, MessageSize.SMALL, FlowWindowSize.LARGE, ChannelType.NIO, maxConcurrentStreams, channelCount);
callCounter = new AtomicLong();
completed = new AtomicBoolean();
startUnaryCalls(maxConcurrentStreams, callCounter, completed, 1);
}
use of org.openjdk.jmh.annotations.Setup in project grpc-java by grpc.
the class TransportBenchmark method setUp.
@Setup
public void setUp() throws Exception {
AbstractServerImplBuilder<?> serverBuilder;
AbstractManagedChannelImplBuilder<?> channelBuilder;
switch(transport) {
case INPROCESS:
{
String name = "bench" + Math.random();
serverBuilder = InProcessServerBuilder.forName(name);
channelBuilder = InProcessChannelBuilder.forName(name);
break;
}
case NETTY:
{
InetSocketAddress address = new InetSocketAddress("localhost", pickUnusedPort());
serverBuilder = NettyServerBuilder.forAddress(address);
channelBuilder = NettyChannelBuilder.forAddress(address).negotiationType(NegotiationType.PLAINTEXT);
break;
}
case NETTY_LOCAL:
{
String name = "bench" + Math.random();
LocalAddress address = new LocalAddress(name);
serverBuilder = NettyServerBuilder.forAddress(address).channelType(LocalServerChannel.class);
channelBuilder = NettyChannelBuilder.forAddress(address).channelType(LocalChannel.class).negotiationType(NegotiationType.PLAINTEXT);
break;
}
case NETTY_EPOLL:
{
InetSocketAddress address = new InetSocketAddress("localhost", pickUnusedPort());
// Reflection used since they are only available on linux.
Class<?> groupClass = Class.forName("io.netty.channel.epoll.EpollEventLoopGroup");
EventLoopGroup group = (EventLoopGroup) groupClass.getConstructor().newInstance();
@SuppressWarnings("unchecked") Class<? extends ServerChannel> serverChannelClass = (Class<? extends ServerChannel>) Class.forName("io.netty.channel.epoll.EpollServerSocketChannel");
serverBuilder = NettyServerBuilder.forAddress(address).bossEventLoopGroup(group).workerEventLoopGroup(group).channelType(serverChannelClass);
@SuppressWarnings("unchecked") Class<? extends Channel> channelClass = (Class<? extends Channel>) Class.forName("io.netty.channel.epoll.EpollSocketChannel");
channelBuilder = NettyChannelBuilder.forAddress(address).eventLoopGroup(group).channelType(channelClass).negotiationType(NegotiationType.PLAINTEXT);
groupToShutdown = group;
break;
}
case OKHTTP:
{
int port = pickUnusedPort();
InetSocketAddress address = new InetSocketAddress("localhost", port);
serverBuilder = NettyServerBuilder.forAddress(address);
channelBuilder = OkHttpChannelBuilder.forAddress("localhost", port).negotiationType(io.grpc.okhttp.NegotiationType.PLAINTEXT);
break;
}
default:
throw new Exception("Unknown transport: " + transport);
}
if (direct) {
serverBuilder.directExecutor();
// Because blocking stubs avoid the executor, this doesn't do much.
channelBuilder.directExecutor();
}
server = serverBuilder.addService(new AsyncServer.BenchmarkServiceImpl()).build();
server.start();
channel = channelBuilder.build();
stub = BenchmarkServiceGrpc.newBlockingStub(channel);
// Wait for channel to start
stub.unaryCall(SimpleRequest.getDefaultInstance());
}
use of org.openjdk.jmh.annotations.Setup in project hazelcast by hazelcast.
the class DefaultPortableReaderPerformanceTest method setup.
@Setup
public void setup() throws Exception {
ss = new DefaultSerializationServiceBuilder().addPortableFactory(DefaultPortableReaderQuickTest.TestPortableFactory.ID, new DefaultPortableReaderQuickTest.TestPortableFactory()).build();
Portable primitive = new DefaultPortableReaderTestStructure.PrimitivePortable();
primitiveReader = reader(primitive);
reader = reader(PORSCHE);
}
use of org.openjdk.jmh.annotations.Setup in project HdrHistogram by HdrHistogram.
the class HdrHistogramRecordingBench method setup.
@Setup
public void setup() throws NoSuchMethodException {
histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
synchronizedHistogram = new SynchronizedHistogram(highestTrackableValue, numberOfSignificantValueDigits);
atomicHistogram = new AtomicHistogram(highestTrackableValue, numberOfSignificantValueDigits);
concurrentHistogram = new ConcurrentHistogram(highestTrackableValue, numberOfSignificantValueDigits);
recorder = new Recorder(highestTrackableValue, numberOfSignificantValueDigits);
singleWriterRecorder = new SingleWriterRecorder(highestTrackableValue, numberOfSignificantValueDigits);
doubleHistogram = new DoubleHistogram(highestTrackableValue, numberOfSignificantValueDigits);
doubleRecorder = new DoubleRecorder(highestTrackableValue, numberOfSignificantValueDigits);
singleWriterDoubleRecorder = new SingleWriterDoubleRecorder(highestTrackableValue, numberOfSignificantValueDigits);
}
use of org.openjdk.jmh.annotations.Setup in project logging-log4j2 by apache.
the class AbstractStringLayoutStringEncodingBenchmark method setUp.
@Setup
public void setUp() {
bytes = new byte[128];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) i;
}
usAsciiGetBytesLayout = new GetBytesLayout(Charset.forName("US-ASCII"));
iso8859_1GetBytesLayout = new GetBytesLayout(Charset.forName("ISO-8859-1"));
utf8GetBytesLayout = new GetBytesLayout(Charset.forName("UTF-8"));
utf16GetBytesLayout = new GetBytesLayout(Charset.forName("UTF-16"));
usAsciiEncodeLayout = new EncodeLayout(Charset.forName("US-ASCII"));
iso8859_1EncodeLayout = new EncodeLayout(Charset.forName("ISO-8859-1"));
utf8EncodeLayout = new EncodeLayout(Charset.forName("UTF-8"));
utf16EncodeLayout = new EncodeLayout(Charset.forName("UTF-16"));
final StringBuilder msg = new StringBuilder();
msg.append(MESSAGE);
logEvent = createLogEvent(new SimpleMessage(msg));
destination = new Destination();
}
Aggregations