Skip to content

Commit

Permalink
Try to smoothen benchmark results, let them be more thruthful
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwalker committed Apr 18, 2015
1 parent c1a6274 commit 9d63945
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,31 @@ class FinaglePingBench {
}

@Benchmark
def async(): Future[String] =
client.doRequest(FinaglePingBench.Ping) {
case BulkReply(message) Future.value(message.toString(Utf8))
}
@OperationsPerInvocation(100000)
def async_100000(): String = {
(1 until 100000).foreach(_ FinaglePingBench.ping(client))
Await.result(FinaglePingBench.ping(client))
}

@Benchmark
@OperationsPerInvocation(10000)
def async_10000(): String = {
(1 until 10000).foreach(_ FinaglePingBench.ping(client))
Await.result(FinaglePingBench.ping(client))
}

@Benchmark
def sync(): String =
Await.result(client.doRequest(FinaglePingBench.Ping) {
case StatusReply(message) Future.value(message)
})
Await.result(FinaglePingBench.ping(client))
}
object FinaglePingBench {
object Ping extends Command {
val command = "PING"
val toChannelBuffer = RedisCodec.toUnifiedFormat(Seq(StringToChannelBuffer("PING")))
}

def ping(client: Client): Future[String] = client.doRequest(Ping) {
case StatusReply(message) Future.value(message)
case BulkReply(message) Future.value(message.toString(Utf8))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,20 @@ class ScalaRedisNbPingBench {
}

@Benchmark
def async(): Future[Ping.Ret] =
client.ping()
@OperationsPerInvocation(100000)
def async_100000(): Boolean = {
(1 until 100000).foreach(_ client.ping())
Await.result(client.ping(), Duration.Inf)
}

@Benchmark
@OperationsPerInvocation(10000)
def async_10000(): Boolean = {
(1 until 10000).foreach(_ client.ping())
Await.result(client.ping(), Duration.Inf)
}

@Benchmark
def sync(): Ping.Ret =
def sync(): Boolean =
Await.result(client.ping(), Duration.Inf)
}
14 changes: 12 additions & 2 deletions benchmarks/src/main/scala/rx/redis/RedissonPingBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@ import java.util.concurrent.TimeUnit
class RedissonPingBench {

@Benchmark
def async(s: RedissonPingBench.AsyncState): concurrent.Future[String] =
s.conn.ping()
@OperationsPerInvocation(10000)
def async_10000(s: RedissonPingBench.AsyncState): Boolean = {
(1 until 10000).foreach(_ s.conn.ping())
s.conn.ping().await(1, TimeUnit.MINUTES)
}

@Benchmark
@OperationsPerInvocation(100000)
def async_100000(s: RedissonPingBench.AsyncState): Boolean = {
(1 until 100000).foreach(_ s.conn.ping())
s.conn.ping().await(1, TimeUnit.MINUTES)
}

@Benchmark
def sync(s: RedissonPingBench.SyncState): String =
Expand Down
13 changes: 11 additions & 2 deletions benchmarks/src/main/scala/rx/redis/RxPingBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,17 @@ class RxPingBench {
}

@Benchmark
def async(): Observable[String] = {
client.ping()
@OperationsPerInvocation(100000)
def async_100000(): String = {
(1 until 100000).foreach(_ client.ping())
client.ping().toBlocking.single()
}

@Benchmark
@OperationsPerInvocation(10000)
def async_10000(): String = {
(1 until 10000).foreach(_ client.ping())
client.ping().toBlocking.single()
}

@Benchmark
Expand Down

0 comments on commit 9d63945

Please sign in to comment.