text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|>monoDeepAttempt(): BigInt = { import reactor.core.publisher.Mono def descent(n: Int): Mono[BigInt] = if (n == depth) Mono.error(new Exception("Oh noes!")) else if (n == halfway) descent(n + 1).onErrorReturn(BigInt.apply(50)) else descent(n + 1).map(_ + n)...
fim
zio/zio
scala
<|fim_suffix|> import cats.effect.IO def loop(i: Int): IO[Int] = if (i < size) IO.race(IO.never, IO.delay(i + 1)).flatMap(_ => loop(i + 1)) else IO.pure(i) loop(0).unsafeRunSync() } @Benchmark def zioEmptyRace(): Int = { def loop(i: Int): UIO[Int] = if (i < size) ZIO.never.raceFi...
fim
zio/zio
scala
<|fim_suffix|>card(fiberRefs)(_.update(_ + 1)))) } yield () } }.getOrThrowFiberFailure() } private def createAndJoinUpdatesDeep(runtime: Runtime[Any]) = Unsafe.unsafe { implicit unsafe => runtime.unsafe.run { ZIO.scoped { ZIO.foreach(1.to(n))(i => FiberRef.make...
fim
zio/zio
scala
<|fim_suffix|>Locally) } } <|fim_prefix|>package zio import org.openjdk.jmh.annotations.{Scope => JScope, _} import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Meas...
fim
zio/zio
scala
<|fim_suffix|> value unsafeRun(io) } @Benchmark def zioForEachUnit(): Int = { val io = for { _ <- ZIO.foreachDiscard(ints)(_ => ZIO.unit) } yield 0 unsafeRun(io) } } <|fim_prefix|>package zio import cats.effect.unsafe.implicits.global import cats.effect.{IO => CIO} import cats.syntax....
fim
zio/zio
scala
<|fim_prefix|>package zio import java.util.concurrent._ import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil._ @Measurement(iterations = 10, time = 3, timeUnit = TimeUnit.SECONDS) @Warmup(iterations = 10, time = 3, timeUnit = TimeUnit.SECONDS) @Fork(2) @Threads(1) @State(JScope.Thread) @Be...
fim
zio/zio
scala
<|fim_prefix|>package zio import java.util.concurrent._ import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil._ @Measurement(iterations = 10, time = 3, timeUnit = TimeUnit.SECONDS) @Warmup(iterations = 10, time = 3, timeUnit =<|fim_suffix|>pe.Thread) @BenchmarkMode(Array(Mode.Throughput)) @...
fim
zio/zio
scala
<|fim_suffix|>oop(0)).getOrThrowFiberFailure() } } } <|fim_prefix|>package zio import cats.effect.unsafe.implicits.global import org.openjdk.jmh.annotations.{Scope => JScope, _} import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array<|fim_middle|>(Mode.Throughput)) @OutputTimeUnit(TimeU...
fim
zio/zio
scala
<|fim_suffix|> Mode Cnt Score Error Units * [info] ForkJoinBenchmark.catsForkJoin 10000 thrpt 10 2913.651 ± 28.332 ops/s * [info] ForkJoinBenchmark.zioForkJoin 10000 thrpt 10 613.202 ± 5.053 ops/s * [info] ForkJoinBenchmark.zioForkJoinNoFiberRoots 10000 thrpt 10 76...
fim
zio/zio
scala
<|fim_prefix|>package zio import org.openjdk.jmh.annotations.{Scope => JScope, _} import org.scalacheck import zio.BenchmarkUtil.unsafeRun import zio.test.Gen import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.NANOSECONDS) class GenBenchmarks ...
fim
zio/zio
scala
<|fim_prefix|>package zio import cats.effect.std.{Queue => CatsQueue} import cats.effect.unsafe.implicits.global import cats.effect.{Fiber => CFiber, IO => CIO, Resource} import cats.syntax.all._ import fs2.concurrent.Topic import io.github.timwspence.cats.stm.{STM => CSTM} import org.openjdk.jmh.annotations.{Scope =>...
fim
zio/zio
scala
<|fim_prefix|>package zio import cats.effect.unsafe.implicits.global import org.openjdk.j<|fim_suffix|>ze) loop(i + 1).flatMap(i => Single.fromCallable(() => i)) else Single.fromCallable(() => i) Single .fromCallable(() => 0) .flatMap(loop(_)) .blockingGet() } @Benchmark def twitter...
fim
zio/zio
scala
<|fim_prefix|>package zio import cats.effect.unsafe.implicits.global import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil._ import java.util.concurrent.TimeUnit import scala.annotation.tailrec @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) c...
fim
zio/zio
scala
<|fim_prefix|>package zio import cats.effect.unsafe.implicits.global import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil._ import java.util.concurrent.TimeUnit import scala.concurrent.Await @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Wa...
fim
zio/zio
scala
package zio import org.openjdk.jmh.annotations.{Scope => JScope, _} import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) class NewEncodingBenchmark { @Param(Array("5", "10")) // , "20", "40")) var depth: Int = _ @Benchmark def c...
fim
zio/zio
scala
<|fim_suffix|>.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Fork(1) @Measurement(iterations = 2, timeUnit = TimeUnit.SECONDS, time = 5) @Warmup(iterations = 5, timeUnit = TimeUnit.SECONDS, time = 5) class ParallelMergeSortBenchmark { @Param(Array("10000")) var size: Int = _ ...
fim
zio/zio
scala
<|fim_suffix|>): Unit = { def createCompleters(promise: Deferred[CIO, Unit], latch: Deferred[CIO, Unit]) = List.range(0, waiters).traverse(_ => (latch.get *> promise.complete(())).start) val io = { for { latch <- Deferred[CIO, Unit] promise <- Deferred[CIO, Unit] waiters <...
fim
zio/zio
scala
<|fim_prefix|>package zio import cats.effect.unsafe.implicits.global import cats.effect.{IO => CIO} import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil._ import zio.stm._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(Tim...
fim
zio/zio
scala
<|fim_suffix|>l(parallelism) { repeat(totalSize * 1 / parallelism)(queue.take) } } @Benchmark def parallel(): Int = { val io = for { offers <- ZIO.forkAll(offers) takes <- ZIO.forkAll(takes) _ <- offers.join _ <- takes.join } yield 0 unsafeRun(io) } ...
fim
zio/zio
scala
<|fim_prefix|>package zio import cats.effect.unsafe.implicits.global import cats.effect.{IO => CIO} import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil._ import zio.stm._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(Tim...
fim
zio/zio
scala
<|fim_prefix|>package zio import cats.effect.unsafe.implicits.global import cats.effect.{IO => CIO} import org.openjdk.jmh.annotations.{Sco<|fim_suffix|> UIO[Unit], max: Int): UIO[Unit] = if (max < 1) ZIO.unit else task.flatMap(_ => repeat(task, max - 1)) val io = for { _ <- repeat(zioTQ.offer(0...
fim
zio/zio
scala
package zio import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil.unsafeRun import zio.stream.{ZPipeline, ZStream} import java.util.concurrent.TimeUnit @State(JScope.Benchmark) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Measurement(iterations = 15, timeUnit =...
fim
zio/zio
scala
<|fim_prefix|>package zio import org.openjdk.jmh.annotations.{Scope => JScope, _} import java.util.concurrent.TimeUnit /** * {{{ * * [info] Benchmark (nesting) Mode Cnt Score Error Units * [info] RegionBenchmark.catsBracket 100 thrpt 5 38666.762 � 268.038 ops/s * [...
fim
zio/zio
scala
<|fim_prefix|>package zio import org.openjdk.jmh.annotations.{Scope => JScope, _} import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time =...
fim
zio/zio
scala
<|fim_suffix|>.blockingGet() } @Benchmark def twitterShallowAttempt(): BigInt = { import com.twitter.util.{Await, Future} import com.twitter.util.{Return, Throw} def throwup(n: Int): Future[BigInt] = if (n == 0) throwup(n + 1).rescue { case _ => Future.value(0) } else if (n...
fim
zio/zio
scala
<|fim_prefix|>package zio import akka.Done import akka.actor.ActorSystem import akka.stream.scaladsl.{Keep, Sink => AkkaSink, Source => AkkaSource} import cats.effect.unsafe.implicits.global import cat<|fim_suffix|> builder ++= alphanumeric(random, min, max) if (col == cols - 1) builder ++= RowSep.toSt...
fim
zio/zio
scala
<|fim_prefix|>package zio import akka.NotUsed import akka.actor.ActorSystem import akka.stream.scaladsl.{Keep, Sink => AkkaSink, Source => AkkaSource} import cats.effect.unsafe.implicits.global import cats.effect.{IO => CatsIO} import fs2.{Chunk => FS2Chunk, Stream => FS2Stream} import org.openjdk.jmh.annotations.{Sco...
fim
zio/zio
scala
<|fim_suffix|>rk.zioRight' 4 thrpt 10 35925377.327 � 1732444.668 ops/s * * [info] UnsafeRunBenchmark.zioRight 8 thrpt 10 2035601.943 � 69795.749 ops/s * [info] UnsafeRunBenchmark.zioRight' 8 thrpt 10 15740140.258 � 672817.959 ops/s * }}} */ @State(JScope.Thread)...
fim
zio/zio
scala
<|fim_prefix|>package zio import org.openjdk.jmh.annotations.{Scope => JScope, _} import org.openjdk.jmh.infra.Blackhole import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) @...
fim
zio/zio
scala
<|fim_suffix|>hanEqual0(ia, ja)) IO.unit else swapIJ(i, ia, j, ja) maybeSwap.flatMap(_ => innerLoop(i, j + 1)) } def swapIJ(i: Int, ia: A, j: Int, ja: A): IO[Unit] = IO { array.update(i, ja); array.update(j, ia) } outerLoop(0) } } <|fim_prefix|>package zio import scala.{Array, Bool...
fim
zio/zio
scala
<|fim_suffix|>ay(n + 2)) @Benchmark def flatMapOptimized(): Array[Int] = { var mappings = List.empty[Array[Int]] var i = 0 var total = 0 while (i < size) { val mapped = Array(array(i) * 2) mappings ::= mapped total += mapped.length i += 1 } val dest = A...
fim
zio/zio
scala
<|fim_prefix|>package<|fim_suffix|>0) @Measurement(iterations = 1) class ChainBenchmarks { val largeChain: Chain[Int] = (0 to 1000).foldLeft(Chain.empty[Int])((acc, _) => acc ++ Chain.fromSeq(0 to 1000)) val largeChunk: Chunk[Int] = (0 to 1000).foldLeft[Chunk[Int]](Chunk.empty)((acc, _) => acc ++ Chunk.fr...
fim
zio/zio
scala
<|fim_prefix|>package zio.chunks import org.openjdk.jmh.annotations._ import zio.Chunk import java.util.concurrent.TimeUnit @State(Scope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Warmup(iterations = 10, time = 10) @Measurement(iterations = 10, time = 10) class ChunkAppendBench...
fim
zio/zio
scala
<|fim_prefix|><|fim_suffix|>chunkHalfSize: Chunk[Int] = _ @Setup def setUp(): Unit = { chunk0 = Chunk.empty chunk1 = Chunk.single(1) chunk10 = Chunk.fill(10)(1) chunkHalfSize = Chunk.fill(size / 2)(1) } @Benchmark def leftConcat0(): Chunk[Int] = { var i = 1 var current = chunk0...
fim
zio/zio
scala
<|fim_suffix|>ector(a01, a02) @Benchmark def vectorCreate04(): Vector[Int] = Vector(a01, a02, a03, a04) @Benchmark def vectorCreate08(): Vector[Int] = Vector(a01, a02, a03, a04, a05, a06, a07, a08) @Benchmark def vectorCreate16(): Vector[Int] = Vector(a01, a02, a03, a04, a05, a06, a07, a08, a09, a10,...
fim
zio/zio
scala
<|fim_prefix|>package zio.chunks import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warm<|fim_suffix|>nit = { val array = (1 to size).toArray chunk = Chu...
fim
zio/zio
scala
package zio.chunks import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 10, time = 10) @Measurement(iterations = 10, time = 10) class ChunkFlat...
fim
zio/zio
scala
<|fim_prefix|>package zio.chunks import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 10, time = 10) @Measurement(iterations = 10, time = 10) c...
fim
zio/zio
scala
<|fim_suffix|>nt] = chunk.collect { case num: Int if num > (size / 2) => num + 1 } @Benchmark def collectFirst(): Option[Int] = chunk.collectFirst { case num: Int if num > (size / 2) => num + 1 } @Benchmark def combinations(): Iterator[Chunk[Int]] = chunk.combinations(size) @Benchmark def contain...
fim
zio/zio
scala
<|fim_suffix|>k.map(_ * 2) @Benchmark def mapStringChunk(): Chunk[String] = stringChunk.map(_ + "123") @Benchmark def mapIntVector(): Vector[Int] = intVector.map(_ * 2) @Benchmark def mapStringVector(): Vector[String] = stringVector.map(_ + "123") @Benchmark def mapIntList(): List[Int] = intList.map...
fim
zio/zio
scala
<|fim_suffix|> listPrepend(): List[Int] = { var i = 0 var current = list while (i < size) { current = i +: current i += 1 } current } } <|fim_prefix|>package zio.chunks import org.openjdk.jmh.annotations._ import zio.Chunk import java.util.concurrent.TimeUnit<|fim_middle|> @...
fim
zio/zio
scala
<|fim_suffix|>Benchmark def chunkUpdate(): Chunk[Int] = { var i = 0 var current = chunk while (i < size) { current = current.updated(i, i) i += 1 } current } @Benchmark def vectorUpdate(): Vector[Int] = { var i = 0 var current = vector while (i < size)...
fim
zio/zio
scala
<|fim_prefix|>package zio.chunks import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 10, time = 10) @Measurement(iterations = 10, time = 10) @...
fim
zio/zio
scala
package zio.internal sealed abstract class BenchQueueType(val name: String) extends Product with Serializable private[this] object BenchQueueType { def lookup(tpe: String): Option[BenchQueueType] = tpe match { case RingBufferPow2Type.name => Some(RingBufferPow2Type) case RingBufferArbType.name ...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal object BenchUtils { def queueByType[A]( tpe: BenchQueueType, capacity: Int ): MutableConcurrentQueue[A] = tpe match { case RingBufferPow2Ty<|fim_suffix|> .lookup(tpe) .fold(sys.error(s"$tpe is not a valid BenchQueueType"))(parsedTpe => queueByType(parsedTpe, ...
fim
zio/zio
scala
package zio.internal import org.openjdk.jmh.annotations._ import org.openjdk.jmh.infra.Blackhole import org.springframework.util.{ConcurrentReferenceHashMap => SpringConcurrentReferenceHashMap} import java.util import java.util.Collections import java.util.concurrent.{ConcurrentLinkedQueue, TimeUnit} import java.util...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil<|fim_suffix|> def foreachParDiscard(): Unit = unsafeRun(ZIO.yieldNow *> ZIO.foreachParDiscard(as)(_ => ZIO.unit)) @Benchmark def foreachForkJoinDiscard(): Unit = unsafeRun(ZIO.yieldNow *> ...
fim
zio/zio
scala
package zio.internal /** * JCToolsQueue is defined only under `benchmarks` so `coreJVM` doesn't have * extra dependency on the whole JCTools. */ class JCToolsQueue[A](desiredCapacity: Int) extends MutableConcurrentQueue[A] { private val jctools = new org.jctools.queues.MpmcArrayQueue[A](desiredCapacity) overri...
fim
zio/zio
scala
<|fim_suffix|> Boolean = jucBlockingQueue.isEmpty override def isFull(): Boolean = false } <|fim_prefix|>package zio.internal import java.util.concurrent.LinkedBlockingQueue class JucBlockingQueue[A] extends MutableConcurrentQueue[A] { override val capacity: Int = Int.MaxValue private val jucBlockingQueue = n...
fim
zio/zio
scala
<|fim_suffix|> _) => ())) @Benchmark def naiveMergeAllPar(): Unit = unsafeRun(naiveMergeAllPar(in)(())((_, _) => ())) private def naiveMergeAllPar[R, E, A, B]( in: Iterable[ZIO[R, E, A]] )(zero: B)(f: (B, A) => B): ZIO[R, E, B] = in.foldLeft[ZIO[R, E, B]](succeed[B](zero))((acc, a) => acc.zipPar(a...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.Unsafe import zio.metrics.MetricKeyType.Frequency import zio.metrics._ import java.time.Instant import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeU...
fim
zio/zio
scala
<|fim_suffix|>dSafeQueue[A](override val capacity: Int) extends MutableConcurrentQueue[A] { private val buf: Array[AnyRef] = Array.ofDim[AnyRef](capacity) var head: Long = 0 var tail: Long = 0 override def offer(a: A): Boolean = if (isFull()) { false } else { ...
fim
zio/zio
scala
<|fim_suffix|>leConcurrentQueue[AnyRef] = _ @Setup(Level.Invocation) def createQ(): Unit = q = queueByType(qType, qCapacity) @Benchmark @OperationsPerInvocation(1 << 16) def offer(): Unit = { val aQ = q var i = 0 while (i < Ops && noUnrolling) { val anEl = mkEl() aQ.offer(anEl)...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import java.util.concurrent.atomic.AtomicReference class OneElementConcQueueNoMetric[A] extends MutableConcurrentQueue[A] { private[this] final val ref = new AtomicReference[AnyRef]() <|fim_suffix|>ef poll(default: A): A = { var ret = default var looping = true val...
fim
zio/zio
scala
<|fim_suffix|>_CONSUMER) } } } object OneElementQueueConcBenchmark { @State(Scope.Thread) @AuxCounters(AuxCounters.Type.EVENTS) class PollCounters(var failedPolls: Long, var madePolls: Long) { def this() = this(0, 0) } @State(Scope.Thread) @AuxCounters(AuxCounters.Type.EVENTS) class OfferCount...
fim
zio/zio
scala
<|fim_suffix|>kEl(): QueueElement = () => 1 val emptyEl: QueueElement = () => -1 var oneElQ: MutableConcurrentQueue[QueueElement] = new OneElementConcurrentQueue var pow2RB: MutableConcurrentQueue[QueueElement] = RingBufferPow2(2) @Setup(Level.Trial) def createQ(): Unit = { oneElQ = new OneElementConcu...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import org.openjdk.jmh.annotations._ import org.openjdk.jmh.infra.{Blackhole, Control} import zio.internal.BenchUtils._ import java.util.concurrent.TimeUnit @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Warmup(iterations = 10, time = 1) @Measuremen...
fim
zio/zio
scala
<|fim_suffix|>pe(qType, qCapacity) @Setup(Level.Invocation) def fill(): Unit = { var i = 0 while (i < Ops) { val anEl = mkEl; q.offer(anEl); i += 1 } } @Benchmark @OperationsPerInvocation(1 << 16) def poll(): Unit = { val aQ = q var i = 0 while (i < Ops && noUnrolling) { aQ.pol...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import org.openjdk.jmh.annotations._ import org.openjdk.jmh.infra.Blackhole import zio.internal.BenchUtils._ import zio.internal.ProducerConsumerBenchmark.{OfferCounters, PollCounters} import java.util.concurrent.TimeUnit @BenchmarkMode(Arra<|fim_suffix|> @Benchmark @Group("Grou...
fim
zio/zio
scala
<|fim_suffix|> @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Fork(value = 1) private[this] class ReduceAllParBenchmark { private val a = ZIO.unit private val as = List.fill(10000)(ZIO.unit) @Benchmark def reduceAllPar(): Unit = unsafeRun(ZIO.reduceAllPar(...
fim
zio/zio
scala
<|fim_suffix|>3, batchSize) doPoll(q3) } @Benchmark @Group("All") @GroupThreads(1) def allPow2(): Int = { doOffer(q1, batchSize) doPoll(q1) } @Benchmark @Group("All") @GroupThreads(1) def allArb(): Int = { doOffer(q2, batchSize) doPoll(q2) } @Benchmark @Group("All") @G...
fim
zio/zio
scala
<|fim_suffix|>t = 0 while (i < batchSize) { val delayed = q.poll(emptyEl) result += delayed() i += 1 } result } } <|fim_prefix|>package zio.internal import org.openjdk.jmh.annotations._ import zio.internal.BenchUtils._ import java.util.concurrent.TimeUnit @OutputTimeUnit(TimeUnit.NANO...
fim
zio/zio
scala
<|fim_suffix|>l dead = WeakConcurrentBagBenchmark.dead.get println(s"dead: ${dead}") println(s"alive: ${dead}") println(s"total: ${dead + alive}") println(s"aliveness: ${alive.toDouble / (alive.toDouble + dead.toDouble)}") } } object WeakConcurrentBagBenchmark { val alive: AtomicLong = new AtomicL...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import cats.effect.{Deferred, IO => CIO} import cats.effect.std.{Queue => CQueue} import cats.effect.unsafe.IORuntime import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio._ import zio.BenchmarkUtil._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @Benchmar...
fim
zio/zio
scala
<|fim_suffix|>ram("exponential", MetricKeyType.Histogram.Boundaries.exponential(1.0, 2.0, 64)).update(i.toDouble) } } } <|fim_prefix|>package zio.metrics import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil._ import zio.ZIO import java.util.concurrent.TimeUnit @State(JScope.Thre...
fim
zio/zio
scala
<|fim_prefix|>package zio.stm import cats.effect.unsafe.implicits.global import cats.effect.{IO => CIO} import io.github.timwspence.cats.stm.{STM => CatsSTM} import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throu...
fim
zio/zio
scala
<|fim_prefix|>package zio.stm import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio._ import java.lang.{Runtime => JRuntime} import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Measurement(iterations = 15, timeUnit = TimeUn...
fim
zio/zio
scala
<|fim_prefix|>package zio.stm import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil._ import zio._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Warmup(iterations = 5, timeUnit = TimeUnit.SECONDS, time =...
fim
zio/zio
scala
<|fim_prefix|>package zio.stm import org.openjdk.jmh.annotations.{Scope => JScope, _} import zio.BenchmarkUtil._ import zio._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Warmup(iterations = 5, timeUnit = TimeUnit.SECONDS, time =...
fim
zio/zio
scala
<|fim_suffix|> @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Measurement(iterations = 15, timeUnit = TimeUnit.SECONDS, time = 3) @Warmup(iterations = 15, timeUnit = TimeUnit.SECONDS, time = 3) @Fork(1) class TArrayOpsBenchmarks { import BenchmarkUtil.unsafeRun @Param(Array("10", "100", ...
fim
zio/zio
scala
<|fim_suffix|> val data = (1 to ops).toList.zipWithIndex val tmap = unsafeRun(TMap.fromIterable(data).commit) val tref = TRef.unsafeMake(data.toMap) val ref = Ref.unsafe.make(data.toMap)(Unsafe.unsafe) def ri() = ThreadLocalRandom.current().nextInt() tmapUpdates =...
fim
zio/zio
scala
<|fim_suffix|> data = (1 to size).toList.zipWithIndex idx = size / 2 map = unsafeRun(TMap.fromIterable(data).commit) } @Benchmark def lookup(): Unit = unsafeRun(ZIO.foreachDiscard(calls)(_ => map.get(idx).commit)) @Benchmark def update(): Unit = unsafeRun(ZIO.foreachDiscard(calls)(_ => map....
fim
zio/zio
scala
<|fim_prefix|>package zio.stm import org.openjdk.jmh.annotations.{Benchmark, Group, GroupThreads, Scope => JScope, _} import org.openjdk.jmh.infra.Blackhole import zio.BenchmarkUtil._ import zio._ import java.util.concurrent.TimeUnit import java.util.concur<|fim_suffix|>riteGroup1(): Unit = javaLockWrite() @Benchm...
fim
zio/zio
scala
<|fim_prefix|>package zio.stm import org.openjdk.jmh.annotations.{Scope => JScope, _<|fim_suffix|>nion(): Unit = unsafeRun(set.union(set).commit) } <|fim_middle|>} import zio._ import java.util.concurrent.TimeUnit @State(JScope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Measure...
fim
zio/zio
scala
<|fim_prefix|>package zio.test import org.openjdk.jmh.annotations._ import zio.Benchmar<|fim_suffix|> unsafeRun(causesEffect) } <|fim_middle|>kUtil._ import zio.{Trace, ZIO} import java.util.concurrent.TimeUnit @State(Scope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) class GenB...
fim
zio/zio
scala
package zio.concurrent import zio.{Chunk, ChunkBuilder, UIO, ZIO} import java.util.concurrent.ConcurrentHashMap import java.util.function.BiConsumer import scala.jdk.CollectionConverters._ /** * Wrapper over `java.util.concurrent.ConcurrentHashMap`. */ final class ConcurrentMap[K, V] private (private val underlyin...
fim
zio/zio
scala
<|fim_prefix|>package zio.concurrent import zio.{UIO, ZIO} import java.util.concurrent.ConcurrentHashMap import java.util.function.{Consumer, Predicate} import scala.jdk.CollectionConverters._ /** * A `ConcurrentSet` is a Set wrapper over * `java.util.concurrent.ConcurrentHashMap`. */ final class ConcurrentSet[A]...
fim
zio/zio
scala
<|fim_prefix|>package zio.concurrent import zio._ /** * A synchronization aid that allows one or more fibers to wait until a set of * operations being performed in other fibers completes. * * A `CountDownLatch` is initialized with a given count. The `await` method * block until the current count reaches zero due...
fim
zio/zio
scala
package zio.concurrent import zio._ import zio.stacktracer.TracingImplicits.disableAutoTrace /** * A synchronization aid that allows a set of fibers to all wait for each other * to reach a common barrier point. * * CyclicBarriers are useful in programs involving a fixed sized party of fibers * that must occasion...
fim
zio/zio
scala
<|fim_prefix|>package zio.concurrent import zio.stm.TRef import zio._ import zio.stm.STM /** * An `MVar[A]` is a mutable location that is either empty or contains a value * of type `A`. It has two fundamental operations: `put` which fills an `MVar` * if it is empty and blocks otherwise, and `take` which empties an...
fim
zio/zio
scala
<|fim_suffix|>s this lock, if owned, * or None otherwise. */ lazy val owner: UIO[Option[FiberId]] = state.get.map(_.holder) /** * Returns the fiber IDs of the fibers that are waiting to acquire this lock. */ lazy val queuedFibers: UIO[List[FiberId]] = state.get.map(_.waiters.keys.toList) /...
fim
zio/zio
scala
<|fim_suffix|>ates the non-existing key with a given value") { for { map <- ConcurrentMap.make(1 -> "a") putRes <- map.putIfAbsent(2, "b") getRes <- map.get(2) } yield assert(putRes)(isNone) && assert(getRes)(isSome(equalTo("b"))) }, test("prese...
fim
zio/zio
scala
<|fim_suffix|> test("toSet") { for { set <- ConcurrentSet.make(1, 2, 3, 4, 5) result <- set.toSet } yield assertTrue(result == Set(1, 2, 3, 4, 5)) }, test("transform") { for { set <- ConcurrentSet.make(1, 2, 3, 4, 5) _ <- set.transform(_ + 10) ...
fim
zio/zio
scala
<|fim_suffix|> assertZIO(CountdownLatch.make(0).exit)(dies(anything)) } ), suite("Operations")( test("Fibers wait and get released when countdown reaches 0") { for { latch <- CountdownLatch.make(100) count <- Ref.make(0) ps <- ZIO.collectAl...
fim
zio/zio
scala
package zio.concurrent import zio._ import zio.test.Assertion._ import zio.test.TestAspect._ import zio.test._ import java.util.concurrent.atomic.AtomicInteger object CyclicBarrierSpec extends ZIOSpecDefault { private val parties = 100 val spec = suite("CyclicBarrierSpec")( test("Construction") { ...
fim
zio/zio
scala
<|fim_suffix|>True) && assert(r2)(isFalse) }, test("update") { for { v <- MVar.empty[Boolean] f <- v.update(!_).fork _ <- v.put(true) _ <- f.join r2 <- v.take } yield assert(r2)(isFalse) } ) } <|fim_prefix|>package zio.concurren...
fim
zio/zio
scala
<|fim_prefix|>package zio.concurrent import zio.test.Assertion._ import zio<|fim_suffix|> .fork _ <- mlatch.await f1 <- (latch1.countDown *> ZIO.scoped( lock.withLock.flatMap(_ => ref.update(_ + 10)) )).fork _ <- (latch1.countDo...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2018-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_suffix|>pecific { private[zio] val globalScheduler: Scheduler = new Scheduler.Internal { import Scheduler.CancelToken private[this] val ConstFalse = () => false override def schedule(task: Runnable, duration: Duration)(implicit unsafe: Unsafe): CancelToken = (duration: @unchecked) match { ...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2017-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); *<|fim_suffix|>itations under the License. */ package zio import zio.stacktracer.TracingImplicits.disableAutoTrace private[zio] trait ExecutorPlatformSpecific <|fim...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2017-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a co<|fim_suffix|>he License at * * http://www.apache.org/licenses/LICENSE-2....
fim
zio/zio
scala
<|fim_prefix|>package zio private[zio] trait QueuePlatformSpecific { // ja<|fim_suffix|>d type ConcurrentDeque[A] = java.util.ArrayDeque[A] } <|fim_middle|>va.util.concurrent.ConcurrentLinkedDeque is not available in ScalaJS or Scala Native, so we use an ArrayDeque instea<|endoftext|>
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2017-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_suffix|>DITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package zio import zio.stacktracer.TracingImplicits.disableAutoTrace private[zio] abstract class SchedulerPlatformSpecific <|fim_prefix|>/* * Cop...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2017-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2017-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "<|fim_suffix|>a.Function1[Any, Unit | Thenable[Unit]] { def apply(e: Any): Unit | Thenable[Unit] = callback(ZIO.fail(e match { case t: Throwable => t ...
fim
zio/zio
scala
<|fim_suffix|>tCode.failure interruptRootFibers(fiberId).as(exitCode) } } yield exitUnsafe(exit0) } } } } <|fim_prefix|>package zio import zio.internal.stacktracer.Tracer import zio.stacktracer.TracingImplicits.disableAutoTrace import scala.annotati...
fim
zio/zio
scala
<|fim_suffix|> the error type * with `f`. */ def toPromiseJSWith(f: E => Throwable)(implicit trace: Trace): URIO[R, JSPromise[A]] = self.foldCause(c => JSPromise.reject(c.squashWith(f)), JSPromise.resolve[A](_)) } private[zio] trait ZIOCompanionPlatformSpecific { self: ZIO.type => /** * Imports a syn...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2017-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2021-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala