Merge pull request #19 from netty/cleaner-close-bench
Add a benchmark that explore the overhead of always attaching a cleaner to buffers
This commit is contained in:
commit
1013c33c3a
@ -44,6 +44,7 @@ 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();
|
private static final Allocator directPooled = Allocator.pooledDirect();
|
||||||
|
private static final Allocator pooledWithCleaner = Allocator.pooledDirectWithCleaner();
|
||||||
|
|
||||||
@Param({"heavy", "light"})
|
@Param({"heavy", "light"})
|
||||||
public String workload;
|
public String workload;
|
||||||
@ -79,6 +80,18 @@ public class MemorySegmentClosedByCleanerBenchmark {
|
|||||||
return process(withCleaner.allocate(256));
|
return process(withCleaner.allocate(256));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
public Buf cleanerClosePooled() throws Exception {
|
||||||
|
return process(pooledWithCleaner.allocate(256));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
public Buf pooledWithCleanerExplicitClose() throws Exception {
|
||||||
|
try (Buf buf = pooledWithCleaner.allocate(256)) {
|
||||||
|
return process(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Buf process(Buf buffer) throws Exception {
|
private Buf process(Buf buffer) throws Exception {
|
||||||
// Simulate some async network server thingy, processing the buffer.
|
// Simulate some async network server thingy, processing the buffer.
|
||||||
var tlr = ThreadLocalRandom.current();
|
var tlr = ThreadLocalRandom.current();
|
||||||
|
Loading…
Reference in New Issue
Block a user