Skip to content

Commit

Permalink
Allow queries to be eagerly constructed (#488)
Browse files Browse the repository at this point in the history
* Add `xNow` variants of ZQuery methods and optimize for eager ops

* Fix scala 3 compiling

* Add `asExit` methods

* Fix scaladoc

* Add note to `ZQuery#succeed`

* Retrigger CI

* fmt
  • Loading branch information
kyri-petrou authored Jun 22, 2024
1 parent 55f511d commit 96f9a1f
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 84 deletions.
13 changes: 10 additions & 3 deletions benchmarks/src/main/scala/zio/query/FromRequestBenchmark.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import zio.{Chunk, ZIO}

import java.util.concurrent.TimeUnit

@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(2)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
@Threads(1)
@State(JScope.Thread)
@BenchmarkMode(Array(Mode.Throughput))
Expand Down Expand Up @@ -43,6 +43,13 @@ class FromRequestBenchmark {
unsafeRunCache(query, Cache.unsafeMake(count))
}

@Benchmark
def fromRequestsCached(): Long = {
val reqs = Chunk.fromIterable((0 until count).map(_ => Req(1)))
val query = ds.queryAll(reqs).map(_.sum.toLong)
unsafeRunCache(query, Cache.unsafeMake(count))
}

@Benchmark
def fromRequestUncached(): Long = {
val query = ZQuery.collectAllBatched(queries).map(_.sum.toLong)
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ crossScalaVersions := Seq.empty
inThisBuild(
List(
name := "ZIO Query",
zioVersion := "2.1.3",
zioVersion := "2.1.4",
developers := List(
Developer(
"kyri-petrou",
Expand Down
Loading

0 comments on commit 96f9a1f

Please sign in to comment.