Skip to content

Commit

Permalink
Fix benchmark, adding content bytes parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
franz1981 committed Jan 24, 2024
1 parent cea2a45 commit 23fb903
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ public class HttpRequestEncoderBenchmark extends AbstractMicrobenchmark {
@Param({ "false", "true" })
public boolean typePollution;

@Param({ "128" })
private int contentBytes;

@Setup(Level.Trial)
public void setup() throws Exception {
byte[] bytes = new byte[256];
byte[] bytes = new byte[contentBytes];
content = Unpooled.buffer(bytes.length);
content.writeBytes(bytes);
ByteBuf testContent = Unpooled.unreleasableBuffer(content.asReadOnly());
Expand Down Expand Up @@ -112,27 +115,34 @@ public void teardown() {

@Benchmark
public void fullMessage() throws Exception {
fullRequest.content().setIndex(0, contentBytes);
encoder.write(context, fullRequest, newPromise());
}

@Benchmark
public void contentLength() throws Exception {
encoder.write(context, contentLengthRequest, newPromise());
lastContent.content().setIndex(0, contentBytes);
encoder.write(context, lastContent, newPromise());
}

@Benchmark
public void chunked() throws Exception {
encoder.write(context, chunkedRequest, newPromise());
lastContent.content().setIndex(0, contentBytes);
encoder.write(context, lastContent, newPromise());
}

@Benchmark
public void differentTypes() throws Exception {
encoder.write(context, contentLengthRequest, newPromise());
lastContent.content().setIndex(0, contentBytes);
encoder.write(context, lastContent, newPromise());
content.setIndex(0, contentBytes);
fullRequest.content().setIndex(0, contentBytes);
encoder.write(context, fullRequest, newPromise());
encoder.write(context, chunkedRequest, newPromise());
lastContent.content().setIndex(0, contentBytes);
encoder.write(context, lastContent, newPromise());
}

Expand Down

0 comments on commit 23fb903

Please sign in to comment.