|
Scala example source code file (IntAccess.scala)
The Scala IntAccess.scala source codepackage scala.collection.parallel.benchmarks.arrays import scala.collection.parallel.benchmarks._ object IntAccess extends BenchCompanion { def collectionName = "array"; def benchName = "access-int"; def apply(sz: Int, p: Int, what: String) = new IntAccess(sz, p, what) override def comparisons = List("any", "cast", "manif", "unknown") override def defaultSize = 100000 } class IntAccess(sz: Int, p: Int, what: String) extends Resetting(n => n, sz, p, what) with UnknownManif[Int] { def companion = IntAccess def runseq {} def runpar {} def runany = { var i = 0 while (i < sz) { val d = anyarray(i).asInstanceOf[Int] i += 1 } } def runcast = { var i = 0 while (i < sz) { val d = Arrays.apply(castarray, i).asInstanceOf[Int] i += 1 } } def runmanif = { var i = 0 while (i < sz) { val d = manifarray(i) if (op(d)) i += 1 i += 1 } } def op(a: Int) = a < 0 def comparisonMap = collection.Map("any" -> runany _, "cast" -> runcast _, "manif" -> runmanif _, "unknown" -> rununknown _) } Other Scala examples (source code examples)Here is a short list of links related to this Scala IntAccess.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.