From 4e25ed74efe7819fc2da1b755410b28d713bc657 Mon Sep 17 00:00:00 2001 From: Michael Steindorfer Date: Tue, 12 Sep 2023 16:57:53 +0200 Subject: [PATCH] Add benchmark for map `get` operation --- .../io/usethesource/capsule/jmh/JmhMapBenchmarks.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/jmh/java/io/usethesource/capsule/jmh/JmhMapBenchmarks.java b/src/jmh/java/io/usethesource/capsule/jmh/JmhMapBenchmarks.java index b550010..79c217c 100644 --- a/src/jmh/java/io/usethesource/capsule/jmh/JmhMapBenchmarks.java +++ b/src/jmh/java/io/usethesource/capsule/jmh/JmhMapBenchmarks.java @@ -381,6 +381,14 @@ public void timeContainsKey(Blackhole bh) { } } + @Benchmark + @OperationsPerInvocation(CACHED_NUMBERS_SIZE) + public void timeGet(Blackhole bh) { + for (int i = 0; i < CACHED_NUMBERS_SIZE; i++) { + bh.consume(testMap.get(cachedNumbers[i])); + } + } + // @Benchmark // @OperationsPerInvocation(CACHED_NUMBERS_SIZE) // public void timeContainsKeyInt(Blackhole bh) {