Skip to content
Snippets Groups Projects
Unverified Commit 81d408ac authored by Hamza Remmal's avatar Hamza Remmal :homes:
Browse files

Add Collection Conversion example from lecture 3

parent 3523f4b6
No related branches found
No related tags found
No related merge requests found
package lecture3
import scala.collection._
import scala.collection.parallel.CollectionConverters.IterableIsParallelizable
import org.scalameter._
object Conversion :
val standardConfig = config (
Key.exec.minWarmupRuns := 10,
Key.exec.maxWarmupRuns := 20,
Key.exec.benchRuns := 20,
Key.verbose := false
) withWarmer new Warmer.Default
val memConfig = config (
Key.exec.minWarmupRuns := 0,
Key.exec.maxWarmupRuns := 0,
Key.exec.benchRuns := 10,
Key.verbose := true
) withWarmer Warmer.Zero
val vector = Vector.fill(10000000)("")
val list = vector.toList
@main def run =
val listTime = standardConfig measure {
list.par
}
println(s"list conversion time $listTime")
val vectorTime = standardConfig measure {
vector.par
}
println(s"vector conversion time $vectorTime")
println(s"difference : ${listTime.value / vectorTime.value}")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment