Skip to content

Commit

Permalink
More large cache benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethshackleton committed Jun 22, 2024
1 parent ca60178 commit 434b07a
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ import org.openjdk.jmh.annotations.State
@State(Scope.Thread)
open class CommonCacheInput {
internal lateinit var cache: CommonLruCache<Any>
internal lateinit var largeCache: CommonLruCache<Any>

@Setup(Level.Iteration)
fun setUp() {
cache = CommonLruCache(1) {}
largeCache = CommonLruCache(64) {}
}
}

Expand All @@ -48,4 +50,36 @@ open class CommonLruCacheBenchmark {
get("1") {}
get("2") {}
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
fun getEntries(input: CommonCacheInput) = input.largeCache.run {
get("1") { "" }
get("2") { "" }
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
fun getManyEntries(input: CommonCacheInput) = input.largeCache.run {
get("0") { "" }
get("1") { "" }
get("2") { "" }
get("3") { "" }
get("4") { "" }
get("5") { "" }
get("6") { "" }
get("7") { "" }
get("8") { "" }
get("9") { "" }
get("2") { "" }
get("3") { "" }
get("9") { "" }
get("4") { "" }
get("5") { "" }
get("0") { "" }
get("8") { "" }
get("6") { "" }
get("1") { "" }
get("7") { "" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,29 @@ open class LinkedLruCacheBenchmark {
get("1") { "" }
get("2") { "" }
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
fun getManyEntries(input: LinkedCacheInput) = input.largeCache.run {
get("0") { "" }
get("1") { "" }
get("2") { "" }
get("3") { "" }
get("4") { "" }
get("5") { "" }
get("6") { "" }
get("7") { "" }
get("8") { "" }
get("9") { "" }
get("2") { "" }
get("3") { "" }
get("9") { "" }
get("4") { "" }
get("5") { "" }
get("0") { "" }
get("8") { "" }
get("6") { "" }
get("1") { "" }
get("7") { "" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ import org.openjdk.jmh.annotations.State
@State(Scope.Thread)
open class StampedCacheInput {
internal lateinit var cache: StampedCache<Any>
internal lateinit var largeCache: StampedCache<Any>

@Setup(Level.Iteration)
fun setUp() {
cache = StampedCache(1) {}
largeCache = StampedCache(64) {}
}
}

Expand All @@ -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") { "" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,29 @@ open class FastLinkedStringMapBenchmark {
getElsePut("1") { "" }
removeKey("1")
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
fun getManyEntriesAccessOrder(input: LinkedMapInput) = input.largeAccessMap.run {
getEntryElsePut("0") { "" }
getEntryElsePut("1") { "" }
getEntryElsePut("2") { "" }
getEntryElsePut("3") { "" }
getEntryElsePut("4") { "" }
getEntryElsePut("5") { "" }
getEntryElsePut("6") { "" }
getEntryElsePut("7") { "" }
getEntryElsePut("8") { "" }
getEntryElsePut("9") { "" }
getEntryElsePut("2") { "" }
getEntryElsePut("3") { "" }
getEntryElsePut("9") { "" }
getEntryElsePut("4") { "" }
getEntryElsePut("5") { "" }
getEntryElsePut("0") { "" }
getEntryElsePut("8") { "" }
getEntryElsePut("6") { "" }
getEntryElsePut("1") { "" }
getEntryElsePut("7") { "" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ import org.openjdk.jmh.annotations.State
@State(Scope.Thread)
open class StampedMapInput {
internal lateinit var map: FastStampedStringMap<Any>
internal lateinit var largeMap: FastStampedStringMap<Any>

@Setup(Level.Iteration)
fun setUp() {
map = FastStampedStringMap(1) {}
largeMap = FastStampedStringMap(64) {}
}
}

Expand All @@ -55,4 +57,29 @@ open class FastStampedStringMapBenchmark {
getEntryElsePut("1") { "" }
removeEntry("1")
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
fun getManyEntries(input: StampedMapInput) = input.largeMap.run {
getEntryElsePut("0") { "" }
getEntryElsePut("1") { "" }
getEntryElsePut("2") { "" }
getEntryElsePut("3") { "" }
getEntryElsePut("4") { "" }
getEntryElsePut("5") { "" }
getEntryElsePut("6") { "" }
getEntryElsePut("7") { "" }
getEntryElsePut("8") { "" }
getEntryElsePut("9") { "" }
getEntryElsePut("2") { "" }
getEntryElsePut("3") { "" }
getEntryElsePut("9") { "" }
getEntryElsePut("4") { "" }
getEntryElsePut("5") { "" }
getEntryElsePut("0") { "" }
getEntryElsePut("8") { "" }
getEntryElsePut("6") { "" }
getEntryElsePut("1") { "" }
getEntryElsePut("7") { "" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,31 @@ open class LinkedHashMapBenchmark {
getOrPut("2") { "" }
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
fun getManyEntriesAccessOrder(input: LinkedHashMapInput) = input.largeAccessOrderMap.run {
getOrPut("0") { "" }
getOrPut("1") { "" }
getOrPut("2") { "" }
getOrPut("3") { "" }
getOrPut("4") { "" }
getOrPut("5") { "" }
getOrPut("6") { "" }
getOrPut("7") { "" }
getOrPut("8") { "" }
getOrPut("9") { "" }
getOrPut("2") { "" }
getOrPut("3") { "" }
getOrPut("9") { "" }
getOrPut("4") { "" }
getOrPut("5") { "" }
getOrPut("0") { "" }
getOrPut("8") { "" }
getOrPut("6") { "" }
getOrPut("1") { "" }
getOrPut("7") { "" }
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
fun getEntryWithRemoval(input: LinkedHashMapInput) = input.smallMap.run {
Expand Down

0 comments on commit 434b07a

Please sign in to comment.