/mobile Handheld Friendly website
Ubuntu : Intel® Q6600® quad-core |
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 |
|---|---|---|---|---|---|
| 12 | 0.32 | 0.28 | 212 | 494 | 7% 10% 93% 14% |
| 16 | 1.16 | 0.97 | 136,912 | 494 | 7% 7% 97% 8% |
| 20 | 18.93 | 14.12 | 462,460 | 494 | 13% 28% 82% 13% |
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.
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) Server VM (build 23.6-b04, mixed mode)
Scala compiler version 2.10.0 -- Copyright 2002-2012, LAMP/EPFL
/* The Computer Language Benchmarks Game http://benchmarksgame.alioth.debian.org/ contributed by Kannan Goundan modified by Isaac Gouy optimized by David Pollak updated to 2.8 by Rex Kerr */ object binarytrees { def main(args: Array[String]) = { val n = try{ args(0).toInt } catch { case _ => 1 } val minDepth = 4 val maxDepth = n max (minDepth+2) def print(name: String, depth: Int, check: Int) = println(name + " of depth " + depth + "\t check: " + check) print("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) var i,sum = 0 while (i < iterations) { i += 1 sum += Tree(i,depth).isum + Tree(-i,depth).isum } print(iterations*2 + "\t trees", depth, sum) depth += 2 } print("long lived tree", maxDepth, longLivedTree.isum) } } final class Tree(i: Int, left: Tree, right: Tree) { def isum: Int = { val tl = left if (tl eq null) i else i + tl.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) } }
Sat, 26 Jan 2013 06:10:02 GMT
MAKE:
mv binarytrees.scala-4.scala binarytrees.scala
/usr/local/src/scala-2.10.0/bin/scalac -optimise -target:jvm-1.7 binarytrees.scala
binarytrees.scala:12: 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
4.78s to complete and log all make actions
COMMAND LINE:
/usr/local/src/jdk1.7.0_11/bin/java -server -XX:+TieredCompilation -XX:+AggressiveOpts -Xbootclasspath/a:/usr/local/src/scala-2.10.0/lib/scala-library.jar:/usr/local/src/scala-2.10.0/lib/akka-actors.jar:/usr/local/src/scala-2.10.0/lib/typesafe-config.jar binarytrees 20
PROGRAM OUTPUT:
stretch tree of depth 21 check: -1
2097152 trees of depth 4 check: -2097152
524288 trees of depth 6 check: -524288
131072 trees of depth 8 check: -131072
32768 trees of depth 10 check: -32768
8192 trees of depth 12 check: -8192
2048 trees of depth 14 check: -2048
512 trees of depth 16 check: -512
128 trees of depth 18 check: -128
32 trees of depth 20 check: -32
long lived tree of depth 20 check: -1