Skip to content

Instantly share code, notes, and snippets.

//> using scala "2.13.13"
package bench
import org.openjdk.jmh.annotations._
import Bench2._
@State(Scope.Benchmark)
class asymptoticOptTests2 {
@Benchmark
@fserra-mdsol
fserra-mdsol / asymptoticOptTests.scala
Created May 25, 2024 17:03
compare asymptotic complexity of pipelined transformations with/without using views
//> using scala "2.13.13"
package bench
import org.openjdk.jmh.annotations._
import Bench._
class asymptoticOptTests {
@Benchmark
def O2n = hundred
// This gist showcase a Circe JSON Decoder for which a null value in a field gets decoded into some
// arbitrary type, instead of being treated as if it was not present in the request and decoded into None.
// This behaviour is semantically unsound, but so are sometimes the business requirements for application development
//> using scala "2.13.10"
//> using lib "io.circe::circe-core::0.14.6"
//> using lib "io.circe::circe-generic::0.14.6"
//> using lib "io.circe::circe-parser::0.14.6"
//> using scala "3.2.2"
val x = 1_000_000
val y = 1000000
@main
def f(): Unit = if (x == y) println("Values are the same!") else println("Nope :-(")
//> using lib "co.fs2::fs2-core:3.2.4"
//> using lib "org.typelevel::cats-effect:3.3.1"
import cats.effect.{ExitCode, IO, IOApp}
import fs2._
object FunctionalStreams extends IOApp {
def run(args: List[String]): IO[ExitCode] = (for {
_ <- IO.pure("a")