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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
package scala.collection.parallel
package immutable
import org.scalacheck._
import org.scalacheck.Gen
import org.scalacheck.Gen._
import org.scalacheck.Prop._
import org.scalacheck.Properties
import org.scalacheck.Arbitrary._
import scala.collection._
import scala.collection.parallel.ops._
class ParallelRangeCheck(val tasksupport: TaskSupport) extends ParallelSeqCheck[Int]("ParallelRange[Int]") with ops.IntSeqOperators {
// ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2)
// ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2)
type CollType = collection.parallel.ParSeq[Int]
def hasStrictOrder = true
def isCheckingViews = false
def ofSize(vals: Seq[Gen[Int]], sz: Int) = unsupported
override def instances(vals: Seq[Gen[Int]]): Gen[Seq[Int]] = sized { start =>
sized { end =>
sized { step =>
new Range(start, end, if (step != 0) step else 1)
}
}
}
def fromSeq(a: Seq[Int]) = a match {
case r: Range =>
val pr = ParRange(r.start, r.end, r.step, false)
pr.tasksupport = tasksupport
pr
case _ =>
val pa = new parallel.mutable.ParArray[Int](a.length)
pa.tasksupport = tasksupport
for (i <- 0 until a.length) pa(i) = a(i)
pa
}
override def traversable2Seq(t: Traversable[Int]): Seq[Int] = t match {
case r: Range => r
case _ => t.toSeq
}
def values = Seq(choose(-100, 100))
}
|