summaryrefslogblamecommitdiff
path: root/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/DiffHalf.scala
blob: 3d4221d945c3c4f95760482bcb9c927eac571f3b (plain) (tree)















































                                                                                                 
package scala.collection.parallel.benchmarks
package parallel_array







class DiffHalf(sz: Int, p: Int, what: String)
extends Resettable[Cont](sz, p, what, (i: Int) => new Cont(i),  new Array[Any](_), classOf[Cont])
with HavingResult[Int] {
  def companion = DiffHalf
  override def repetitionsPerRun = 400

  val similar = {
    val p = new collection.parallel.mutable.ParallelArray[Cont](sz)
    for (i <- 0 until sz) p(i) = what match {
      case "seq" => arr(i).asInstanceOf[Cont]
      case "par" => pa(i)
    }
    p.drop(p.size / 2)
  }

  def runpar = runresult = pa.diff(similar).size
  def runseq = runresult = sequentialDiff(similar, sz).size
  override def comparisonMap = collection.Map()

  val corr = (a: Cont, b: Cont) => a.in == b.in
}

object DiffHalf extends Companion {
  def benchName = "diff-half";
  def apply(sz: Int, p: Int, what: String) = new DiffHalf(sz, p, what)
  override def comparisons = List()
  override def defaultSize = 10000
}