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.620.31208786  35% 39% 90% 45%
4,0002.140.7027,324786  73% 74% 71% 96%
16,00027.497.0885,596786  96% 99% 97% 97%

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 #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 Nov 2014 04:22:38 GMT

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

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play