-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
232 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
plugins { | ||
kotlin("jvm") | ||
kotlin("plugin.allopen") version "2.0.20" | ||
id("org.jetbrains.kotlinx.benchmark") version "0.4.11" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.11") | ||
implementation(project(":")) | ||
implementation(libs.testcontainer.redis) | ||
implementation("redis.clients:jedis:5.2.0") | ||
implementation("io.github.crackthecodeabhi:kreds:0.9.1") | ||
} | ||
|
||
allOpen.annotation("org.openjdk.jmh.annotations.State") | ||
|
||
benchmark { | ||
targets.register("main") | ||
} |
37 changes: 37 additions & 0 deletions
37
benchmarks/src/main/kotlin/eu/vendeli/rethis/benchmarks/JedisBenchmark.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package eu.vendeli.rethis.benchmarks | ||
|
||
import kotlinx.benchmark.* | ||
import org.openjdk.jmh.annotations.Timeout | ||
import redis.clients.jedis.JedisPooled | ||
import java.util.concurrent.TimeUnit | ||
|
||
@BenchmarkMode(Mode.Throughput) | ||
@State(Scope.Benchmark) | ||
@Warmup(iterations = 2, time = 1000, timeUnit = TimeUnit.MILLISECONDS) | ||
@Measurement(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS) | ||
@Timeout(time = 10, timeUnit = TimeUnit.SECONDS) | ||
class JedisBenchmark { | ||
private lateinit var jedis: JedisPooled | ||
|
||
@Setup | ||
fun setup() { | ||
jedis = JedisPooled("localhost", 6379) | ||
jedis.ping() | ||
} | ||
|
||
@TearDown | ||
fun tearDown() { | ||
jedis.close() | ||
} | ||
|
||
@Benchmark | ||
fun jedisSet(bh: Blackhole) { | ||
|
||
bh.consume(jedis.set("key", "value")) | ||
} | ||
|
||
@Benchmark | ||
fun jedisGet(bh: Blackhole) { | ||
bh.consume(jedis.get("key")) | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
benchmarks/src/main/kotlin/eu/vendeli/rethis/benchmarks/KredsBenchmark.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package eu.vendeli.rethis.benchmarks | ||
|
||
import io.github.crackthecodeabhi.kreds.connection.Endpoint | ||
import io.github.crackthecodeabhi.kreds.connection.KredsClient | ||
import io.github.crackthecodeabhi.kreds.connection.newClient | ||
import kotlinx.benchmark.Benchmark | ||
import kotlinx.benchmark.Blackhole | ||
import kotlinx.benchmark.Setup | ||
import kotlinx.benchmark.TearDown | ||
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.launch | ||
import org.openjdk.jmh.annotations.* | ||
import java.util.concurrent.TimeUnit | ||
|
||
@DelicateCoroutinesApi | ||
@BenchmarkMode(Mode.Throughput) | ||
@State(Scope.Benchmark) | ||
@Warmup(iterations = 2, time = 1000, timeUnit = TimeUnit.MILLISECONDS) | ||
@Measurement(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS) | ||
@Timeout(time = 10, timeUnit = TimeUnit.SECONDS) | ||
class KredsBenchmark { | ||
private lateinit var kreds: KredsClient | ||
|
||
@Setup | ||
fun setup() { | ||
kreds = newClient(Endpoint("localhost", 6379)) | ||
GlobalScope.launch { | ||
// kreds.use { it.ping("test") } | ||
kreds.ping("test") | ||
} | ||
} | ||
|
||
@TearDown | ||
fun tearDown() { | ||
kreds.close() | ||
} | ||
|
||
@Benchmark | ||
fun kredsSet(bh: Blackhole) { | ||
GlobalScope.launch { | ||
bh.consume( | ||
kreds.set("key", "value"), | ||
// kreds.use { it.set("key", "value") }, | ||
) | ||
} | ||
} | ||
|
||
@Benchmark | ||
fun kredsGet(bh: Blackhole) { | ||
GlobalScope.launch { | ||
bh.consume( | ||
// kreds.use { it.get("key") } | ||
kreds.get("key"), | ||
) | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
benchmarks/src/main/kotlin/eu/vendeli/rethis/benchmarks/RethisBenchmark.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package eu.vendeli.rethis.benchmarks | ||
|
||
import eu.vendeli.rethis.ReThis | ||
import eu.vendeli.rethis.commands.get | ||
import eu.vendeli.rethis.commands.ping | ||
import eu.vendeli.rethis.commands.set | ||
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.launch | ||
import org.openjdk.jmh.annotations.* | ||
import org.openjdk.jmh.infra.Blackhole | ||
import java.util.concurrent.TimeUnit | ||
|
||
@DelicateCoroutinesApi | ||
@BenchmarkMode(Mode.Throughput) | ||
@State(Scope.Benchmark) | ||
@Warmup(iterations = 2, time = 1000, timeUnit = TimeUnit.MILLISECONDS) | ||
@Measurement(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS) | ||
@Timeout(time = 10, timeUnit = TimeUnit.SECONDS) | ||
class RethisBenchmark { | ||
private lateinit var rethis: ReThis | ||
|
||
@Setup | ||
fun setup() { | ||
rethis = ReThis("localhost", 6379) | ||
GlobalScope.launch { rethis.ping("test") } | ||
} | ||
|
||
@TearDown | ||
fun tearDown() { | ||
rethis.disconnect() | ||
} | ||
|
||
@Benchmark | ||
fun rethisSet(bh: Blackhole) { | ||
GlobalScope.launch { | ||
bh.consume(rethis.runCatching { set("key", "value") }) | ||
} | ||
} | ||
|
||
@Benchmark | ||
fun rethisGet(bh: Blackhole) { | ||
GlobalScope.launch { | ||
bh.consume(rethis.runCatching { get("key") }) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
rootProject.name = "re.this" | ||
|
||
include("benchmarks") | ||
|
||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.