blob: 9c6ac19229608fc575ee16f0b773feb3404dc0ea (
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
|
package scala.collection.parallel.benchmarks.parallel_array
object CountList extends Companion {
def benchName = "count-list";
def apply(sz: Int, parallelism: Int, what: String) = new CountList(sz, parallelism, what)
override def comparisons = List("jsr")
override def defaultSize = 1000
val listCreator = (i: Int) => (0 until (i % 50 + 50)).toList
val pred = (lst: List[Int]) => check(lst)
val predjsr = new extra166y.Ops.Predicate[List[Int]] {
def op(lst: List[Int]) = check(lst)
}
def check(lst: List[Int]) = lst.foldLeft(0)((sum, n) => sum + n * n) % 2 == 0
}
class CountList(sz: Int, p: Int, what: String)
extends Resettable(sz, p, what, CountList.listCreator, new Array[Any](_), classOf[List[Int]]) {
def companion = CountList
override def repetitionsPerRun = 250
def runpar = pa.count(CountList.pred)
def runseq = sequentialCount(CountList.pred, sz)
def runjsr = jsrarr.withFilter(CountList.predjsr).size
def comparisonMap = collection.Map("jsr" -> runjsr _)
}
|