RedisEncoderBenchmark Class — netty Architecture
Architecture documentation for the RedisEncoderBenchmark class in RedisEncoderBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c0bad0b8_2a8e_1783_0199_88c007f3f64d["RedisEncoderBenchmark"] a250e3f5_5400_98e2_77c0_656c3a8deb30["RedisEncoderBenchmark.java"] c0bad0b8_2a8e_1783_0199_88c007f3f64d -->|defined in| a250e3f5_5400_98e2_77c0_656c3a8deb30 4a89d274_66a6_c1a0_3405_ea0979fcc7cc["setup()"] c0bad0b8_2a8e_1783_0199_88c007f3f64d -->|method| 4a89d274_66a6_c1a0_3405_ea0979fcc7cc e7f779a3_037f_0f83_eb21_34cd64cccb5f["teardown()"] c0bad0b8_2a8e_1783_0199_88c007f3f64d -->|method| e7f779a3_037f_0f83_eb21_34cd64cccb5f 4620b40c_1022_33cf_af4c_11297cc7b5dc["writeArray()"] c0bad0b8_2a8e_1783_0199_88c007f3f64d -->|method| 4620b40c_1022_33cf_af4c_11297cc7b5dc 9d15c71a_7170_9f41_08f3_89486c851882["ChannelPromise()"] c0bad0b8_2a8e_1783_0199_88c007f3f64d -->|method| 9d15c71a_7170_9f41_08f3_89486c851882
Relationship Graph
Source Code
microbench/src/main/java/io/netty/microbench/redis/RedisEncoderBenchmark.java lines 45–101
@State(Scope.Benchmark)
@Fork(1)
@Threads(1)
@Warmup(iterations = 5)
@Measurement(iterations = 5)
public class RedisEncoderBenchmark extends AbstractMicrobenchmark {
private RedisEncoder encoder;
private ByteBuf content;
private ChannelHandlerContext context;
private ArrayRedisMessage redisArray;
@Param({ "true", "false" })
public boolean pooledAllocator;
@Param({ "true", "false" })
public boolean voidPromise;
@Param({ "50", "200", "1000" })
public int arraySize;
@Setup(Level.Trial)
public void setup() {
byte[] bytes = new byte[256];
content = Unpooled.buffer(bytes.length);
content.writeBytes(bytes);
ByteBuf testContent = Unpooled.unreleasableBuffer(content.asReadOnly());
List<RedisMessage> rList = new ArrayList<RedisMessage>(arraySize);
for (int i = 0; i < arraySize; ++i) {
rList.add(new FullBulkStringRedisMessage(testContent));
}
redisArray = new ArrayRedisMessage(rList);
encoder = new RedisEncoder();
context = new EmbeddedChannelWriteReleaseHandlerContext(pooledAllocator ? PooledByteBufAllocator.DEFAULT :
UnpooledByteBufAllocator.DEFAULT, encoder) {
@Override
protected void handleException(Throwable t) {
handleUnexpectedException(t);
}
};
}
@TearDown(Level.Trial)
public void teardown() {
content.release();
content = null;
}
@Benchmark
public void writeArray() throws Exception {
encoder.write(context, redisArray.retain(), newPromise());
}
private ChannelPromise newPromise() {
return voidPromise ? context.voidPromise() : context.newPromise();
}
}
Source
Frequently Asked Questions
What is the RedisEncoderBenchmark class?
RedisEncoderBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/redis/RedisEncoderBenchmark.java.
Where is RedisEncoderBenchmark defined?
RedisEncoderBenchmark is defined in microbench/src/main/java/io/netty/microbench/redis/RedisEncoderBenchmark.java at line 45.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free