/mobile Handheld Friendly website
Ubuntu : Intel® Q6600® one 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 |
|---|---|---|---|---|---|
| 1,000 | 0.49 | 0.51 | 15,856 | 724 | 0% 0% 4% 100% |
| 4,000 | 3.52 | 3.53 | 20,096 | 724 | 0% 0% 1% 100% |
| 16,000 | 48.22 | 48.24 | 49,932 | 724 | 0% 0% 0% 100% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read mandelbrot 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/ original contributed by Isaac Gouy made to use single array and parallelized by Stephen Marsh converted to Scala 2.8 by Rex Kerr */ import java.io.BufferedOutputStream object mandelbrot { var size: Int = 0 var bytesPerRow: Int = 0 var bitmap: Array[Byte] = _ var donerows: Array[Boolean] = _ var nextRow = 0 val limitSquared = 4.0 val max = 50 def getNextRow: Int = synchronized { notify() // wakes up main thread if (nextRow == size) return -1 nextRow += 1 return nextRow - 1 } def main(args: Array[String]) { size = args(0).toInt bytesPerRow = (size+7)/8 // ceiling of (size / 8) bitmap = new Array(bytesPerRow*size) donerows = new Array(size) for (i <- 0 until Runtime.getRuntime().availableProcessors()) new Thread(new CalcThread()).start() // main thread prints rows as they finish println("P4\n" + size + " " + size) val w = new BufferedOutputStream(System.out) var y = 0 while (y < size) { while (!donerows(y)) synchronized{wait()} w.write(bitmap, y * bytesPerRow, bytesPerRow) y += 1 } w.close } class CalcThread extends Runnable { def run () { while (true) { var y = getNextRow if (y == -1) return var bits = 0 var bitnum = 0 var x = 0 var aindex = y * bytesPerRow while (x < size) { val cr = 2.0 * x / size - 1.5 val ci = 2.0 * y / size - 1.0 var zr, tr, zi, ti = 0.0 var j = max do { zi = 2.0 * zr * zi + ci zr = tr - ti + cr ti = zi*zi tr = zr*zr j = j - 1 } while (!(tr + ti > limitSquared) && j > 0) bits = bits << 1 if (!(tr + ti > limitSquared)) bits += 1 bitnum += 1 if (x == size - 1) { bits = bits << (8 - bitnum) bitnum = 8 } if (bitnum == 8) { bitmap(aindex) = bits.toByte aindex += 1 bits = 0 bitnum = 0 } x += 1 } donerows(y) = true } } } }
Sat, 26 Jan 2013 21:45:39 GMT MAKE: mv mandelbrot.scala mandelbrot.scala mv: `mandelbrot.scala' and `mandelbrot.scala' are the same file make: [mandelbrot.scala_run] Error 1 (ignored) /usr/local/src/scala-2.10.0/bin/scalac -optimise -target:jvm-1.7 mandelbrot.scala 10.39s 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 mandelbrot 16000 (BINARY) PROGRAM OUTPUT NOT SHOWN