Merge pull request #9 from netty/more-close-benchmarks

Add benchmark for closing pooled buffers
This commit is contained in:
Chris Vest 2020-12-01 11:46:42 +01:00 committed by GitHub
commit e039f6f7f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,6 +43,7 @@ import static java.util.concurrent.CompletableFuture.completedFuture;
public class MemorySegmentClosedByCleanerBenchmark { public class MemorySegmentClosedByCleanerBenchmark {
private static final Allocator direct = Allocator.direct(); private static final Allocator direct = Allocator.direct();
private static final Allocator withCleaner = Allocator.directWithCleaner(); private static final Allocator withCleaner = Allocator.directWithCleaner();
private static final Allocator directPooled = Allocator.pooledDirect();
@Param({"heavy", "light"}) @Param({"heavy", "light"})
public String workload; public String workload;
@ -66,6 +67,13 @@ public class MemorySegmentClosedByCleanerBenchmark {
} }
} }
@Benchmark
public Buf explicitPooledClose() throws Exception {
try (Buf buf = process(directPooled.allocate(256))) {
return buf;
}
}
@Benchmark @Benchmark
public Buf cleanerClose() throws Exception { public Buf cleanerClose() throws Exception {
return process(withCleaner.allocate(256)); return process(withCleaner.allocate(256));