-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into update/scala-library-2.13.5
- Loading branch information
Showing
32 changed files
with
1,242 additions
and
52 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
55 changes: 55 additions & 0 deletions
55
benchmarks/src/main/scala/zio/redis/hash/HDelBenchmarks.scala
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,55 @@ | ||
package zio.redis.hash | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
import zio.ZIO | ||
import zio.redis.{ BenchmarkRuntime, hDel, hSet } | ||
|
||
@State(Scope.Thread) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
@Measurement(iterations = 15) | ||
@Warmup(iterations = 15) | ||
@Fork(2) | ||
class HDelBenchmarks extends BenchmarkRuntime { | ||
@Param(Array("500")) | ||
private var size: Int = _ | ||
|
||
private var items: List[(String, String)] = _ | ||
|
||
private val key = "test-hash" | ||
|
||
@Setup(Level.Trial) | ||
def setup(): Unit = { | ||
items = (0 to size).map(e => e.toString -> e.toString).toList | ||
zioUnsafeRun(hSet(key, items.head, items.tail: _*).unit) | ||
} | ||
|
||
@Benchmark | ||
def laserdisc(): Unit = { | ||
import _root_.laserdisc.fs2._ | ||
import _root_.laserdisc.{ all => cmd, _ } | ||
import cats.implicits.toFoldableOps | ||
import cats.instances.list._ | ||
unsafeRun[LaserDiscClient](c => items.traverse_(it => c.send(cmd.hdel(Key.unsafeFrom(key), Key.unsafeFrom(it._1))))) | ||
} | ||
|
||
@Benchmark | ||
def rediculous(): Unit = { | ||
import cats.implicits._ | ||
import io.chrisdavenport.rediculous._ | ||
unsafeRun[RediculousClient](c => items.traverse_(it => RedisCommands.hdel[RedisIO](key, List(it._1)).run(c))) | ||
} | ||
|
||
@Benchmark | ||
def redis4cats(): Unit = { | ||
import cats.instances.list._ | ||
import cats.syntax.foldable._ | ||
unsafeRun[Redis4CatsClient[String]](c => items.traverse_(it => c.hDel(key, it._1))) | ||
} | ||
|
||
@Benchmark | ||
def zio(): Unit = zioUnsafeRun(ZIO.foreach_(items)(it => hDel(key, it._1))) | ||
} |
57 changes: 57 additions & 0 deletions
57
benchmarks/src/main/scala/zio/redis/hash/HExistsBenchmarks.scala
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,57 @@ | ||
package zio.redis.hash | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
import zio.ZIO | ||
import zio.redis.{ BenchmarkRuntime, hExists, hSet } | ||
|
||
@State(Scope.Thread) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
@Measurement(iterations = 15) | ||
@Warmup(iterations = 15) | ||
@Fork(2) | ||
class HExistsBenchmarks extends BenchmarkRuntime { | ||
@Param(Array("500")) | ||
private var size: Int = _ | ||
|
||
private var items: List[(String, String)] = _ | ||
|
||
private val key = "test-hash" | ||
|
||
@Setup(Level.Trial) | ||
def setup(): Unit = { | ||
items = (0 to size).map(e => e.toString -> e.toString).toList | ||
zioUnsafeRun(hSet(key, items.head, items.tail: _*).unit) | ||
} | ||
|
||
@Benchmark | ||
def laserdisc(): Unit = { | ||
import _root_.laserdisc.fs2._ | ||
import _root_.laserdisc.{ all => cmd, _ } | ||
import cats.implicits.toFoldableOps | ||
import cats.instances.list._ | ||
unsafeRun[LaserDiscClient](c => | ||
items.traverse_(it => c.send(cmd.hexists(Key.unsafeFrom(key), Key.unsafeFrom(it._1)))) | ||
) | ||
} | ||
|
||
@Benchmark | ||
def rediculous(): Unit = { | ||
import cats.implicits._ | ||
import io.chrisdavenport.rediculous._ | ||
unsafeRun[RediculousClient](c => items.traverse_(it => RedisCommands.hexists[RedisIO](key, it._1).run(c))) | ||
} | ||
|
||
@Benchmark | ||
def redis4cats(): Unit = { | ||
import cats.instances.list._ | ||
import cats.syntax.foldable._ | ||
unsafeRun[Redis4CatsClient[String]](c => items.traverse_(it => c.hExists(key, it._1))) | ||
} | ||
|
||
@Benchmark | ||
def zio(): Unit = zioUnsafeRun(ZIO.foreach_(items)(it => hExists(key, it._1))) | ||
} |
55 changes: 55 additions & 0 deletions
55
benchmarks/src/main/scala/zio/redis/hash/HGetAllBenchmarks.scala
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,55 @@ | ||
package zio.redis.hash | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
import zio.ZIO | ||
import zio.redis.{ BenchmarkRuntime, hGetAll, hSet } | ||
|
||
@State(Scope.Thread) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
@Measurement(iterations = 15) | ||
@Warmup(iterations = 15) | ||
@Fork(2) | ||
class HGetAllBenchmarks extends BenchmarkRuntime { | ||
@Param(Array("500")) | ||
private var size: Int = _ | ||
|
||
private var items: List[(String, String)] = _ | ||
|
||
private val key = "test-hash" | ||
|
||
@Setup(Level.Trial) | ||
def setup(): Unit = { | ||
items = (0 to size).map(e => e.toString -> e.toString).toList | ||
zioUnsafeRun(hSet(key, items.head, items.tail: _*).unit) | ||
} | ||
|
||
@Benchmark | ||
def laserdisc(): Unit = { | ||
import _root_.laserdisc.fs2._ | ||
import _root_.laserdisc.{ all => cmd, _ } | ||
import cats.implicits.toFoldableOps | ||
import cats.instances.list._ | ||
unsafeRun[LaserDiscClient](c => items.traverse_(_ => c.send(cmd.hgetall(Key.unsafeFrom(key))))) | ||
} | ||
|
||
@Benchmark | ||
def rediculous(): Unit = { | ||
import cats.implicits._ | ||
import io.chrisdavenport.rediculous._ | ||
unsafeRun[RediculousClient](c => items.traverse_(_ => RedisCommands.hgetall[RedisIO](key).run(c))) | ||
} | ||
|
||
@Benchmark | ||
def redis4cats(): Unit = { | ||
import cats.instances.list._ | ||
import cats.syntax.foldable._ | ||
unsafeRun[Redis4CatsClient[String]](c => items.traverse_(_ => c.hGetAll(key))) | ||
} | ||
|
||
@Benchmark | ||
def zio(): Unit = zioUnsafeRun(ZIO.foreach_(items)(_ => hGetAll(key))) | ||
} |
56 changes: 56 additions & 0 deletions
56
benchmarks/src/main/scala/zio/redis/hash/HGetBenchmarks.scala
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,56 @@ | ||
package zio.redis.hash | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
import zio.ZIO | ||
import zio.redis.{ BenchmarkRuntime, hGet, hSet } | ||
|
||
@State(Scope.Thread) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
@Measurement(iterations = 15) | ||
@Warmup(iterations = 15) | ||
@Fork(2) | ||
class HGetBenchmarks extends BenchmarkRuntime { | ||
@Param(Array("500")) | ||
private var size: Int = _ | ||
|
||
private var items: List[(String, String)] = _ | ||
|
||
private val key = "test-hash" | ||
|
||
@Setup(Level.Trial) | ||
def setup(): Unit = { | ||
items = (0 to size).map(e => e.toString -> e.toString).toList | ||
zioUnsafeRun(hSet(key, items.head, items.tail: _*).unit) | ||
} | ||
|
||
@Benchmark | ||
def laserdisc(): Unit = { | ||
import _root_.laserdisc.fs2._ | ||
import _root_.laserdisc.{ all => cmd, _ } | ||
import cats.implicits.toFoldableOps | ||
import cats.instances.list._ | ||
unsafeRun[LaserDiscClient](c => | ||
items.traverse_(it => c.send(cmd.hget[String](Key.unsafeFrom(key), Key.unsafeFrom(it._1)))) | ||
) | ||
} | ||
|
||
@Benchmark | ||
def rediculous(): Unit = { | ||
import cats.implicits._ | ||
import io.chrisdavenport.rediculous._ | ||
unsafeRun[RediculousClient](c => items.traverse_(it => RedisCommands.hget[RedisIO](key, it._1).run(c))) | ||
} | ||
|
||
@Benchmark | ||
def redis4cats(): Unit = { | ||
import cats.syntax.foldable._ | ||
unsafeRun[Redis4CatsClient[String]](c => items.traverse_(it => c.hGet(key, it._1))) | ||
} | ||
|
||
@Benchmark | ||
def zio(): Unit = zioUnsafeRun(ZIO.foreach_(items)(it => hGet(key, it._1))) | ||
} |
63 changes: 63 additions & 0 deletions
63
benchmarks/src/main/scala/zio/redis/hash/HIncrbyBenchmarks.scala
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,63 @@ | ||
package zio.redis.hash | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
import zio.ZIO | ||
import zio.redis.{ BenchmarkRuntime, hIncrBy, hSet } | ||
|
||
@State(Scope.Thread) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
@Measurement(iterations = 15) | ||
@Warmup(iterations = 15) | ||
@Fork(2) | ||
class HIncrbyBenchmarks extends BenchmarkRuntime { | ||
@Param(Array("500")) | ||
private var size: Int = _ | ||
|
||
@Param(Array("1")) | ||
private var increment: Long = _ | ||
|
||
private var items: List[(String, String)] = _ | ||
|
||
private val key = "test-hash" | ||
|
||
@Setup(Level.Trial) | ||
def setup(): Unit = { | ||
items = (0 to size).map(e => e.toString -> e.toString).toList | ||
zioUnsafeRun(hSet(key, items.head, items.tail: _*).unit) | ||
} | ||
|
||
@Benchmark | ||
def laserdisc(): Unit = { | ||
import _root_.laserdisc.fs2._ | ||
import cats.implicits.toFoldableOps | ||
import _root_.laserdisc.{ all => cmd, _ } | ||
import cats.instances.list._ | ||
unsafeRun[LaserDiscClient](c => | ||
items.traverse_(it => | ||
c.send(cmd.hincrby(Key.unsafeFrom(key), Key.unsafeFrom(it._1), NonZeroLong.unsafeFrom(increment))) | ||
) | ||
) | ||
} | ||
|
||
@Benchmark | ||
def rediculous(): Unit = { | ||
import cats.implicits._ | ||
import io.chrisdavenport.rediculous._ | ||
unsafeRun[RediculousClient](c => | ||
items.traverse_(it => RedisCommands.hincrby[RedisIO](key, it._1, increment).run(c)) | ||
) | ||
} | ||
|
||
@Benchmark | ||
def redis4cats(): Unit = { | ||
import cats.syntax.foldable._ | ||
unsafeRun[Redis4CatsClient[Long]](c => items.traverse_(it => c.hIncrBy(key, it._1, increment))) | ||
} | ||
|
||
@Benchmark | ||
def zio(): Unit = zioUnsafeRun(ZIO.foreach_(items)(it => hIncrBy(key, it._1, increment))) | ||
} |
62 changes: 62 additions & 0 deletions
62
benchmarks/src/main/scala/zio/redis/hash/HIncrbyFloatBenchmarks.scala
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,62 @@ | ||
package zio.redis.hash | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
import zio.ZIO | ||
import zio.redis.{ BenchmarkRuntime, hIncrByFloat, hSet } | ||
|
||
@State(Scope.Thread) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
@Measurement(iterations = 15) | ||
@Warmup(iterations = 15) | ||
@Fork(2) | ||
class HIncrbyFloatBenchmarks extends BenchmarkRuntime { | ||
@Param(Array("500")) | ||
private var size: Int = _ | ||
@Param(Array("1.0")) | ||
private var increment: Double = _ | ||
|
||
private var items: List[(String, String)] = _ | ||
|
||
private val key = "test-hash" | ||
|
||
@Setup(Level.Trial) | ||
def setup(): Unit = { | ||
items = (0 to size).map(e => e.toString -> e.toString).toList | ||
zioUnsafeRun(hSet(key, items.head, items.tail: _*).unit) | ||
} | ||
|
||
@Benchmark | ||
def laserdisc(): Unit = { | ||
import _root_.laserdisc.fs2._ | ||
import _root_.laserdisc.{ all => cmd, _ } | ||
import cats.implicits.toFoldableOps | ||
import cats.instances.list._ | ||
unsafeRun[LaserDiscClient](c => | ||
items.traverse_(it => | ||
c.send(cmd.hincrby(Key.unsafeFrom(key), Key.unsafeFrom(it._1), NonZeroDouble.unsafeFrom(increment))) | ||
) | ||
) | ||
} | ||
|
||
@Benchmark | ||
def rediculous(): Unit = { | ||
import cats.implicits._ | ||
import io.chrisdavenport.rediculous._ | ||
unsafeRun[RediculousClient](c => | ||
items.traverse_(it => RedisCommands.hincrbyfloat[RedisIO](key, it._1, increment).run(c)) | ||
) | ||
} | ||
|
||
@Benchmark | ||
def redis4cats(): Unit = { | ||
import cats.syntax.foldable._ | ||
unsafeRun[Redis4CatsClient[Long]](c => items.traverse_(it => c.hIncrByFloat(key, it._1, increment))) | ||
} | ||
|
||
@Benchmark | ||
def zio(): Unit = zioUnsafeRun(ZIO.foreach_(items)(it => hIncrByFloat(key, it._1, increment))) | ||
} |
Oops, something went wrong.