blob: 47ae108c4513213cc7ca778ca6d0a3ea16bc0431 (
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
|
package scala.collection.parallel.benchmarks
package parallel_array
class ReverseMap(sz: Int, p: Int, what: String)
extends Resettable[Cont](sz, p, what, (i: Int) => new Cont(i), new Array[Any](_), classOf[Cont]) {
def companion = ReverseMap
override def repetitionsPerRun = 100
def runpar = pa.reverseMap(compl)
def runseq = sequentialReverseMap(compl, sz)
override def comparisonMap = collection.Map()
val id = (c: Cont) => c
val compl = (c: Cont) => {
var in = c.in
var i = 2
while (i < 6) {
if (in % i == 0) in = 0
i += 1
}
if (in < 0) null
else c
}
}
object ReverseMap extends Companion {
def benchName = "reverse-map";
def apply(sz: Int, p: Int, what: String) = new ReverseMap(sz, p, what)
override def comparisons = List()
override def defaultSize = 100000
}
|