performance measurements

Each table row shows performance measurements for this Scala program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
12Failed  641   

Read the ↓ make, command line, and program output logs to see how this program was run.

Read binary-trees benchmark to see what this program should do.

 notes

java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Server VM (build 25.0-b70, mixed mode)

Scala compiler version 2.10.3 -- Copyright 2002-2013, LAMP/EPFL

 binary-trees Scala #2 program source code

/* The Computer Language Benchmarks Game
   http://benchmarksgame.alioth.debian.org/

   contributed by Kannan Goundan
   modified by Isaac Gouy
   optimized by David Pollak
   updated for 2.8 and parallelized by Rex Kerr
*/

import scala.actors.Futures._

object binarytrees {
  def report(name: String, depth: Int, check: Int) =
    println(name + " of depth " + depth + "\t check: " + check)

  def main(args: Array[String]) = {
    val n = try{ args(0).toInt } catch { case _ => 1 }
    val minDepth = 4
    val maxDepth = n max (minDepth+2)
    val threads = 3  // More than 3 tends to overwhelm GC

    report("stretch tree", maxDepth+1, Tree(0,maxDepth+1).isum)
    val longLivedTree = Tree(0,maxDepth)
    var depth = minDepth
    while (depth <= maxDepth) {
      val iterations = 1 << (maxDepth - depth + minDepth)
      val limits = (0 to threads).map(_*iterations/threads).sliding(2).toList
      val check = limits.map(i => future(Go(i(0)+1,i(1),depth).calc))
      report(iterations*2 + "\t trees", depth, check.map(_()).sum)
      depth += 2
    }
    report("long lived tree", maxDepth, longLivedTree.isum)
  }
}

case class Sum(var sum: Int) {
  def +=(i: Int) = { sum+=i; this }
}

case class Go(i0: Int, i1: Int, depth: Int) {
  def calc = (Sum(0) /: (i0 to i1))((s,i) =>
    s += Tree(i,depth).isum + Tree(-i,depth).isum
  ).sum
}

final class Tree(i: Int, left: Tree, right: Tree) {
  def isum: Int = if (left eq null) i else i + left.isum - right.isum
}
object Tree {
  def apply(i: Int, depth: Int): Tree = {
    if (depth > 0) new Tree(i, Tree(i*2-1, depth-1), Tree(i*2, depth-1))
    else new Tree(i, null, null)
  }
}

 make, command-line, and program output logs

Wed, 19 Mar 2014 08:26:20 GMT

MAKE:
mv binarytrees.scala-2.scala binarytrees.scala
/usr/local/src/scala-2.10.3/bin/scalac -optimise -target:jvm-1.7 binarytrees.scala
binarytrees.scala:17: warning: This catches all Throwables. If this is really intended, use `case _ : Throwable` to clear this warning.
    val n = try{ args(0).toInt } catch { case _ => 1 }
                                              ^
one warning found
5.08s to complete and log all make actions

COMMAND LINE:
 /usr/local/src/jdk1.8.0/bin/java -server -XX:+TieredCompilation -XX:+AggressiveOpts  -Xbootclasspath/a:/usr/local/src/scala-2.10.3/lib/scala-library.jar:/usr/local/src/scala-2.10.3/lib/akka-actors.jar:/usr/local/src/scala-2.10.3/lib/typesafe-config.jar binarytrees 12

PROGRAM FAILED 


PROGRAM OUTPUT:
stretch tree of depth 13	 check: -1

Exception in thread "main" java.lang.NoClassDefFoundError: scala/actors/Futures$
	at binarytrees$$anonfun$2.apply(binarytrees.scala:28)
	at binarytrees$$anonfun$2.apply(binarytrees.scala:28)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
	at scala.collection.immutable.List.foreach(List.scala:318)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at binarytrees$.main(binarytrees.scala:28)
	at binarytrees.main(binarytrees.scala)
Caused by: java.lang.ClassNotFoundException: scala.actors.Futures$
	at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 9 more

Revised BSD license

  Home   Conclusions   License   Play