Skip to content

Commit

Permalink
logging benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Dec 2, 2023
1 parent 4186373 commit 01407b3
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 5 deletions.
14 changes: 9 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,15 @@ lazy val `kyo-bench` =
.settings(
`kyo-settings`,
`without-cross-scala`,
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.2",
libraryDependencies += "dev.zio" %% "zio" % zioVersion,
libraryDependencies += "dev.zio" %% "zio-concurrent" % zioVersion,
libraryDependencies += "com.softwaremill.ox" %% "core" % "0.0.14",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.16" % Test
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.2",
libraryDependencies += "org.typelevel" %% "log4cats-core" % "2.6.0",
libraryDependencies += "org.typelevel" %% "log4cats-slf4j" % "2.6.0",
libraryDependencies += "dev.zio" %% "zio-logging" % "2.1.16",
libraryDependencies += "dev.zio" %% "zio-logging-slf4j2" % "2.1.16",
libraryDependencies += "dev.zio" %% "zio" % zioVersion,
libraryDependencies += "dev.zio" %% "zio-concurrent" % zioVersion,
libraryDependencies += "com.softwaremill.ox" %% "core" % "0.0.14",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.16" % Test
)

lazy val rewriteReadmeFile = taskKey[Unit]("Rewrite README file")
Expand Down
51 changes: 51 additions & 0 deletions kyo-bench/src/main/scala/kyo/bench/LoggingBench.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package kyo.bench

class LoggingBench extends Bench.SyncAndFork[Unit] {

val depth = 10000

def kyoBench() = {
import kyo._
import kyo.ios._
import kyo.logs._
def loop(i: Int): Unit > IOs =
if (i > depth)
()
else
Logs.error("test").flatMap { _ =>
loop(i + 1)
}
loop(0)
}

def catsBench() = {
import cats.effect._
import org.typelevel.log4cats.slf4j.Slf4jLogger
import cats.effect.unsafe.implicits.global

val logger = Slf4jLogger.create[IO].unsafeRunSync()

def loop(i: Int): IO[Unit] =
if (i > depth)
IO.unit
else
logger.error("test").flatMap { _ =>
loop(i + 1)
}
loop(0)
}

def zioBench() = {
import zio._
import zio.logging.backend.SLF4J

def loop(i: Int): UIO[Unit] =
if (i > depth)
ZIO.unit
else
ZIO.logError("test").flatMap { _ =>
loop(i + 1)
}
loop(0).provide(Runtime.removeDefaultLoggers)
}
}

0 comments on commit 01407b3

Please sign in to comment.