Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit 1013c33

Browse files
authored
Merge pull request #19 from netty/cleaner-close-bench
Add a benchmark that explore the overhead of always attaching a cleaner to buffers
2 parents 6697840 + 5697af4 commit 1013c33

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/java/io/netty/buffer/api/benchmarks/MemorySegmentClosedByCleanerBenchmark.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class MemorySegmentClosedByCleanerBenchmark {
4444
private static final Allocator direct = Allocator.direct();
4545
private static final Allocator withCleaner = Allocator.directWithCleaner();
4646
private static final Allocator directPooled = Allocator.pooledDirect();
47+
private static final Allocator pooledWithCleaner = Allocator.pooledDirectWithCleaner();
4748

4849
@Param({"heavy", "light"})
4950
public String workload;
@@ -79,6 +80,18 @@ public Buf cleanerClose() throws Exception {
7980
return process(withCleaner.allocate(256));
8081
}
8182

83+
@Benchmark
84+
public Buf cleanerClosePooled() throws Exception {
85+
return process(pooledWithCleaner.allocate(256));
86+
}
87+
88+
@Benchmark
89+
public Buf pooledWithCleanerExplicitClose() throws Exception {
90+
try (Buf buf = pooledWithCleaner.allocate(256)) {
91+
return process(buf);
92+
}
93+
}
94+
8295
private Buf process(Buf buffer) throws Exception {
8396
// Simulate some async network server thingy, processing the buffer.
8497
var tlr = ThreadLocalRandom.current();

0 commit comments

Comments
 (0)