From 3129bbc10d2bb43a481f840a8d569b9bb0d57fc3 Mon Sep 17 00:00:00 2001 From: "Kenneth J. Shackleton" Date: Sat, 22 Jun 2024 17:19:01 +0100 Subject: [PATCH] More large cache benchmarks. --- .../selekt/cache/benchmarks/CommonLruCacheBenchmark.kt | 9 +++++++++ .../selekt/cache/benchmarks/StampedCacheBenchmark.kt | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/selekt-java/src/jmh/kotlin/com/bloomberg/selekt/cache/benchmarks/CommonLruCacheBenchmark.kt b/selekt-java/src/jmh/kotlin/com/bloomberg/selekt/cache/benchmarks/CommonLruCacheBenchmark.kt index 711cee5d86..bcee577839 100644 --- a/selekt-java/src/jmh/kotlin/com/bloomberg/selekt/cache/benchmarks/CommonLruCacheBenchmark.kt +++ b/selekt-java/src/jmh/kotlin/com/bloomberg/selekt/cache/benchmarks/CommonLruCacheBenchmark.kt @@ -28,10 +28,12 @@ import org.openjdk.jmh.annotations.State @State(Scope.Thread) open class CommonCacheInput { internal lateinit var cache: CommonLruCache + internal lateinit var largeCache: CommonLruCache @Setup(Level.Iteration) fun setUp() { cache = CommonLruCache(1) {} + largeCache = CommonLruCache(64) {} } } @@ -48,4 +50,11 @@ open class CommonLruCacheBenchmark { get("1") {} get("2") {} } + + @Benchmark + @BenchmarkMode(Mode.Throughput) + fun getEntries(input: CommonCacheInput) = input.largeCache.run { + get("1") { "" } + get("2") { "" } + } } diff --git a/selekt-java/src/jmh/kotlin/com/bloomberg/selekt/cache/benchmarks/StampedCacheBenchmark.kt b/selekt-java/src/jmh/kotlin/com/bloomberg/selekt/cache/benchmarks/StampedCacheBenchmark.kt index 91d5176ebe..cb41bfef48 100644 --- a/selekt-java/src/jmh/kotlin/com/bloomberg/selekt/cache/benchmarks/StampedCacheBenchmark.kt +++ b/selekt-java/src/jmh/kotlin/com/bloomberg/selekt/cache/benchmarks/StampedCacheBenchmark.kt @@ -28,10 +28,12 @@ import org.openjdk.jmh.annotations.State @State(Scope.Thread) open class StampedCacheInput { internal lateinit var cache: StampedCache + internal lateinit var largeCache: StampedCache @Setup(Level.Iteration) fun setUp() { cache = StampedCache(1) {} + largeCache = StampedCache(64) {} } } @@ -48,4 +50,11 @@ open class StampedCacheBenchmark { get("1") {} get("2") {} } + + @Benchmark + @BenchmarkMode(Mode.Throughput) + fun getEntries(input: StampedCacheInput) = input.largeCache.run { + get("1") { "" } + get("2") { "" } + } }