Skip to content

Commit

Permalink
KAFKA-12895: Add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
frankvicky committed Oct 1, 2024
1 parent ab266bc commit a7ebc6c
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,23 @@ public void testCopyOnWriteMapEntrySet(Blackhole blackhole) {
}
}
}

@Benchmark
@OperationsPerInvocation(TIMES)
public void testConcurrentHashMapComputeIfAbsentReadOnly(Blackhole blackhole) {
for (int i = 0; i < TIMES; i++) {
blackhole.consume(concurrentHashMap.computeIfAbsent(
ThreadLocalRandom.current().nextInt(0, mapSize),
newValue -> Integer.MAX_VALUE
));
}
}

@Benchmark
@OperationsPerInvocation(TIMES)
public void testConcurrentHashMapGetReadOnly(Blackhole blackhole) {
for (int i = 0; i < TIMES; i++) {
blackhole.consume(concurrentHashMap.get(ThreadLocalRandom.current().nextInt(0, mapSize)));
}
}
}

0 comments on commit a7ebc6c

Please sign in to comment.