Created
May 25, 2024 18:41
-
-
Save fserra-mdsol/d36320855b65d1b4ff658683526d9c1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using scala "2.13.13" | |
package bench | |
import org.openjdk.jmh.annotations._ | |
import Bench2._ | |
@State(Scope.Benchmark) | |
class asymptoticOptTests2 { | |
@Benchmark | |
def On = initial.foreach(foo => | |
initial.find(_.value == foo.value).map(_.ss).getOrElse(List.empty) | |
) | |
@Benchmark | |
def O1 = | |
initial.foreach(foo => map.getOrElse(foo.value, List.empty)) | |
} | |
object Bench2 { | |
case class Foo(value: Int, ss: List[String]) | |
val initial = List.range(1,100).map(i => Foo(i, List.range(1,i).map(_.toString))) | |
val map = initial.groupMapReduce(_.value)(_.ss)(_ ::: _) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment