Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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}")