blob: 1c1cd52120a99a15eae550f47fb412c628c787ae (
plain) (
blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package scala.collection.parallel
package benchmarks.parallel_view
import scala.collection.parallel.benchmarks.generic._
import scala.collection.SeqView
trait DummyViewBenches
extends ParSeqViewBenches[Dummy, ParSeqView[Dummy, ParSeq[Dummy], Seq[Dummy]], Seq[Dummy]] {
def nameOfCollection = "ParView"
def operators = DummyOperators
def comparisonMap = collection.Map()
val forkJoinPool = new scala.concurrent.forkjoin.ForkJoinPool
def createSequential(sz: Int, p: Int) = {
val s = new Array[Dummy](sz)
for (i <- 0 until sz) s(i) = new Dummy(i)
s
}
def createParallel(sz: Int, p: Int) = {
val pa = new collection.parallel.mutable.ParArray[Dummy](sz)
forkJoinPool.setParallelism(p)
for (i <- 0 until sz) pa(i) = new Dummy(i)
val v = pa.view
collection.parallel.tasksupport.environment = forkJoinPool
v
}
def createSeqView(sz: Int, p: Int) = createSequential(sz, p).view
}
object DummyViewBenchList extends DummyViewBenches
|