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
5000.470.41252404  93% 7% 7% 15%
3,0005.094.9518,284404  1% 100% 3% 2%
5,50016.0415.9718,536404  99% 1% 0% 2%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read spectral-norm 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) Server VM (build 25.0-b70, mixed mode)

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

 spectral-norm Scala program source code

/* The Computer Language Benchmarks Game
   http://benchmarksgame.alioth.debian.org/
   contributed by Isaac Gouy
   modified by Meiko Rachimow
   updated for 2.8 by Rex Kerr
*/

object spectralnorm {
  def main(args: Array[String]) = {
    val n = (if (args.length>0) args(0).toInt else 100)
    printf("%.09f\n", (new SpectralNorm(n)).approximate())
  }
}

class SpectralNorm(n: Int) {

  // Ordinary and transposed versions of infinite matrix
  val A = (i: Int, j: Int) => 1.0/((i+j)*(i+j+1)/2 +i+1)
  val At = (j: Int, i: Int) => 1.0/((i+j)*(i+j+1)/2 +i+1)

  // Matrix multiplication w <- M*v
  def mult(v: Array[Double], w: Array[Double], M: (Int,Int)=> Double ) {
    var i = 0
    while (i < n) {
     var s = 0.0
     var j = 0
     while (j < n) { s += M(i,j)*v(j); j += 1 }
     w(i) =  s
     i += 1
    }
  }

  def approximate() = {
    val u,v,w = Array.fill(n)(1.0)

    var i = 0
    while (i < 10) {
      // Multiply by matrix & transpose
      mult(u,w,A)
      mult(w,v,At)
      mult(v,w,A)
      mult(w,u,At)
      i += 1
    }

    var vbv,vv = 0.0
    i = 0
    while (i < n) {
      vbv += u(i)*v(i)
      vv += v(i)*v(i)
      i += 1
    }

    math.sqrt(vbv/vv)
  }
}

 make, command-line, and program output logs

Wed, 19 Mar 2014 08:00:04 GMT

MAKE:
mv spectralnorm.scala spectralnorm.scala
mv: ‘spectralnorm.scala’ and ‘spectralnorm.scala’ are the same file
make: [spectralnorm.scala_run] Error 1 (ignored)
/usr/local/src/scala-2.10.3/bin/scalac -optimise -target:jvm-1.7 spectralnorm.scala
3.91s 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 spectralnorm 5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play