|
Scala example source code file (CountList.scala)
The Scala CountList.scala source codepackage 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 _) } Other Scala examples (source code examples)Here is a short list of links related to this Scala CountList.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.