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,0000.400.40800786  0% 3% 0% 100%
4,0002.302.3058,840786  0% 0% 1% 100%
16,00028.4328.44239,568786  0% 1% 1% 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.

 notes

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

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

 mandelbrot Scala #4 program source code

/* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 *
 * contributed by Benedikt Nordhoff
 * direct translation from Java #2 by Stefan Krause et al.
 */

import java.io._
import java.util.concurrent.atomic._

object mandelbrot {
  var out:Array[Array[Byte]] = null
  var yCt:AtomicInteger = null
  var Crb:Array[Double] = null
  var Cib:Array[Double] = null
  
  def getByte(x:Int, y:Int) : Int = {
    var res=0;
    for(i <- 0 until 8 by 2){
      var Zr1=Crb(x+i)
      var Zi1=Cib(y)
      
      var Zr2=Crb(x+i+1)
      var Zi2=Cib(y)
      
      var b=0
      var j=49
      var goOn = true
      do{
        val nZr1=Zr1*Zr1-Zi1*Zi1+Crb(x+i)
        val nZi1=Zr1*Zi1+Zr1*Zi1+Cib(y)
        Zr1=nZr1;Zi1=nZi1
         
        val nZr2=Zr2*Zr2-Zi2*Zi2+Crb(x+i+1);
        val nZi2=Zr2*Zi2+Zr2*Zi2+Cib(y);
        Zr2=nZr2;Zi2=nZi2;
         
        if(Zr1*Zr1+Zi1*Zi1>4){b|=2;goOn = b != 3}
        if(Zr2*Zr2+Zi2*Zi2>4){b|=1;goOn = b!=3}
        j-=1
      }while(j>0&& goOn)
      res=(res<<2)+b;
    }
    return res^(-1);
  }

  def putLine(y:Int, line:Array[Byte]){
    for (xb <- 0 until line.length)
      line(xb)=getByte(xb*8,y).toByte
  }

  def main(args:Array[String]) {
    var N=6000
    if (args.length>=1) N = args(0).toInt
    
    Crb=new Array[Double](N+7); Cib=new Array[Double](N+7)
    val invN=2.0/N; for(i <- 0 until N){ Cib(i)=i*invN-1.0; Crb(i)=i*invN-1.5; }
    yCt=new AtomicInteger()
    out=Array.ofDim(N,(N+7)/8)
    
    val pool=new Array[Thread](2*Runtime.getRuntime().availableProcessors())
    for (i <- 0 until pool.length)
      pool(i)=new Thread(){
        override def run() {
          var y=0; while({y=yCt.getAndIncrement();y}<out.length) putLine(y,out(y))
        }
      }
    for (t <- pool) t.start()
    for (t <- pool) t.join()

    val stream = new BufferedOutputStream(System.out)
    stream.write(("P4\n"+N+" "+N+"\n").getBytes())
    for(i<- 0 until N) stream.write(out(i))
    stream.close()
   }
}

 make, command-line, and program output logs

Wed, 19 Mar 2014 05:04:00 GMT

MAKE:
mv mandelbrot.scala-4.scala mandelbrot.scala
/usr/local/src/scala-2.10.3/bin/scalac -optimise -target:jvm-1.7 mandelbrot.scala
5.19s 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 mandelbrot 16000

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play