alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (ObjectAccess.scala)

This example Scala source code file (ObjectAccess.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

benchcompanion, int, int, list, objectaccess, objectaccess, resetting, resetting, string, string, unknownmanif

The Scala ObjectAccess.scala source code

package scala.collection.parallel.benchmarks.arrays


import scala.collection.parallel.benchmarks._



object ObjectAccess extends BenchCompanion {
  def collectionName = "array";
  def benchName = "access-obj";
  def apply(sz: Int, p: Int, what: String) = new ObjectAccess(sz, p, what)
  override def comparisons = List("any", "cast", "gencast", "manif", "unknown")
  override def defaultSize = 100000
}


class ObjectAccess(sz: Int, p: Int, what: String)
extends Resetting(Dummy(_), sz, p, what) with UnknownManif[Dummy] {
  def companion = ObjectAccess
  
  def runseq {}
  def runpar {}
  
  def runany = {
    var i = 0
    while (i < sz) {
      val d = anyarray(i).asInstanceOf[Dummy]
      Dummy.dummyOp(d)
      i += 1
    }
  }
  
  def runcast = {
    var i = 0
    while (i < sz) {
      val d = Arrays.apply(castarray, i).asInstanceOf[Dummy]
      i += 1
    }
  }
  
  def rungenericcast = {
    var i = 0
    while (i < sz) {
      val d = Arrays.genericApply(gencastarray, i)
      i += 1
    }
  }
  
  def runmanif = {
    var i = 0
    while (i < sz) {
      val d = manifarray(i)
      if (d.in < 0) i += 1
      i += 1
    }
  }
  
  def comparisonMap = collection.Map("any" -> runany _, "cast" -> runcast _, "gencast" -> rungenericcast _,
                                     "manif" -> runmanif _, "unknown" -> rununknown _)
  
}














Other Scala examples (source code examples)

Here is a short list of links related to this Scala ObjectAccess.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.