Skip to content

Commit

Permalink
Merge branch 'master' into update/scala-library-2.13.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mijicd authored Mar 10, 2021
2 parents 18b8b57 + fa55323 commit 6baaf09
Show file tree
Hide file tree
Showing 32 changed files with 1,242 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fail-fast: false
matrix:
java: ['adopt@1.8', 'adopt@1.11']
scala: ['2.12.12', '2.13.5']
scala: ['2.12.13', '2.13.5']
steps:
- name: Checkout current branch
uses: actions/checkout@v2.3.4
Expand Down
55 changes: 55 additions & 0 deletions benchmarks/src/main/scala/zio/redis/hash/HDelBenchmarks.scala
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 benchmarks/src/main/scala/zio/redis/hash/HExistsBenchmarks.scala
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 benchmarks/src/main/scala/zio/redis/hash/HGetAllBenchmarks.scala
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 benchmarks/src/main/scala/zio/redis/hash/HGetBenchmarks.scala
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 benchmarks/src/main/scala/zio/redis/hash/HIncrbyBenchmarks.scala
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)))
}
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)))
}
Loading

0 comments on commit 6baaf09

Please sign in to comment.