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
1,000Failed  796   

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.

 notes

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) Server VM (build 25.25-b02, mixed mode)

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

 mandelbrot Scala #3 program source code

/* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 * original contributed by Kenneth Jonsson
 */

import scala.actors.Actor
import scala.actors.Actor._

class Worker(size: Int) extends Actor {
    private val bytesPerRow = (size + 7) >> 3
    private val maxIterations = 50
    private val limitSquared = 4.0

    // Calculate all pixes for one row [-i..i], the real-part
    // coordinate is constant throughout this method
    private def calcRow(rowNum: Int): (Actor, Int, Array[Byte]) = {
	var rowBitmap = new Array[Byte](bytesPerRow)
	var column = 0
	val ci = 2.0 * rowNum / size - 1.0

	while (column < size) {
	    val cr = 2.0 * column / size - 1.5
	    var zr, tr, zi, ti = 0.0
            var iterations = 0

            do {
		zi = 2 * zr * zi + ci
		zr = tr - ti + cr
		ti = zi * zi
		tr = zr * zr
		iterations += 1
            } while (tr + ti <= limitSquared && iterations < maxIterations)

	    if (tr + ti <= limitSquared)
		rowBitmap(column >> 3) = (rowBitmap(column >> 3)
					  | (0x80 >> (column & 7))).toByte

            column += 1
	}
	return (self, rowNum, rowBitmap)
    }

    def act() {
	while (true) {
	    receive {
		case rowNum: Int =>
		    reply(calcRow(rowNum))
		case "EXIT" =>
		    exit()
	    }
	}
    }
}

class MandelbrotCoordinator(size: Int) extends Actor {

    private var nextRowNum = 0
    private var rowsRemaining = size
    private var bitmap = new Array[Array[Byte]](size)

    private def calcNextRow(worker: Actor) {
	if (nextRowNum == size)
	    // All rows has been dispatched, tell the worker to exit
	    worker ! "EXIT"
	else {
	    worker ! nextRowNum
	    nextRowNum += 1
	}
    }

    def act() {
	for (i <- 1 to Runtime.getRuntime().availableProcessors()) {
	    val worker = new Worker(size)
	    // Keep two rows in flight per worker to avoid any worker
	    // idle time, probably not neccessary on a quad-core
	    // machine but might help at higher core count...
	    calcNextRow(worker)
	    calcNextRow(worker)
	    worker.start
	}

	while (true) {
	    receive {
		case (sender: Actor, rowNum: Int, rowBitmap: Array[Byte]) =>
		    calcNextRow(sender)
		    bitmap(rowNum) = rowBitmap
		    rowsRemaining -= 1
		    if (rowsRemaining == 0) {
			// The image is finished, write it to stdout and exit
			println("P4\n" + size + " " + size)
			bitmap.foreach(row => System.out.write(row, 0, row.length))
			exit()
		    }
	    }
	}
    }
}

object mandelbrot {
    def main(args: Array[String]) {
	val coordinator = new MandelbrotCoordinator(args(0).toInt)
	coordinator.start
    }
}

 make, command-line, and program output logs

Wed, 19 Nov 2014 07:45:37 GMT

MAKE:
mv mandelbrot.scala-3.scala mandelbrot.scala
/usr/local/src/scala-2.11.4/bin/scalac -optimise -target:jvm-1.8 mandelbrot.scala
warning: there were 5 deprecation warnings; re-run with -deprecation for details
one warning found
5.03s to complete and log all make actions

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

PROGRAM FAILED 


(BINARY) PROGRAM OUTPUT NOT SHOWN

Exception in thread "main" java.lang.NoClassDefFoundError: scala/actors/Actor
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
	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)
	at mandelbrot$.main(mandelbrot.scala:101)
	at mandelbrot.main(mandelbrot.scala)
Caused by: java.lang.ClassNotFoundException: scala.actors.Actor
	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)
	... 14 more

Revised BSD license

  Home   Conclusions   License   Play