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.450.4522,496720  0% 0% 0% 100%
3,0005.465.4625,384720  0% 1% 1% 100%
5,50017.5917.6025,408720  0% 1% 1% 100%

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) 64-Bit Server VM (build 25.0-b70, mixed mode)

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

 spectral-norm Scala #2 program source code

/* The Computer Language Benchmarks Game

   http://benchmarksgame.alioth.debian.org/

   contributed by Eric Willigers

   based on Java version by The Anh Tran

*/

object spectralnorm {
   val nthread = Runtime.getRuntime.availableProcessors
   val barrier = new java.util.concurrent.CyclicBarrier(nthread)

   def main(args: Array[String]) {
      val n = if (args.length > 0) Integer parseInt args(0)  else 1000
      val fmt = new java.text.DecimalFormat("#.000000000")
      println(fmt format run(n))
   }

   def run(n: Int) = {
      val u = new Array[Double](n)
      val v = new Array[Double](n)
      val tmp = new Array[Double](n)
      val chunk = n / nthread
      var vBv = 0.
      var vv = 0.
      java.util.Arrays.fill(u, 1.)
      Array range(0, nthread) map { i =>
         val rbegin = i * chunk
         val rend = if (i < (nthread -1)) rbegin + chunk else n
         new Approximate(u, v, tmp, rbegin, rend)         
      } foreach { a=>
         a join()
         vBv += a.m_vBv
         vv += a.m_vv
      }
      Math sqrt(vBv/vv)
   }

   final class Approximate(u: Array[Double], v: Array[Double], tmp: Array[Double], rbegin: Int, rend: Int) extends Thread {
      var m_vBv = 0.
      var m_vv = 0.
      start()

      override def run() {
         for (i <- 0 until 10) {
            MultiplyAtAv(u, tmp, v)
            MultiplyAtAv(v, tmp, u)            
         }
         for (i <- rbegin until rend) {
            m_vBv += u(i) * v(i)
            m_vv  += v(i) * v(i)
         }
      }

      @inline
      def eval_A(i: Int, j: Int) = 1.0 / ( ((i+j) * (i+j+1) >>> 1) +i+1 )

      def MultiplyAv(v: Array[Double], Av: Array[Double]) {
         for (i <- rbegin until rend) {
            var sum = 0.
            var j = 0
            while (j < v.length) {
               sum += eval_A(i, j) * v(j)
               j += 1
            }
            Av(i) = sum
         }
      }

      def MultiplyAtv(v: Array[Double], Atv: Array[Double]) {
         for (i <- rbegin until rend) {
            var sum = 0.
            var j = 0
            while (j < v.length) {
               sum += eval_A(j, i) * v(j)
               j += 1
            }
            Atv(i) = sum
         }
      }

      def MultiplyAtAv(v: Array[Double], tmp: Array[Double], AtAv: Array[Double]) {
         MultiplyAv(v, tmp)
         barrier await()
         MultiplyAtv(tmp, AtAv)
         barrier await()
      }
   }
}

 make, command-line, and program output logs

Wed, 19 Mar 2014 06:09:29 GMT

MAKE:
mv spectralnorm.scala-2.scala spectralnorm.scala
/usr/local/src/scala-2.10.3/bin/scalac -optimise -target:jvm-1.7 spectralnorm.scala
warning: there were 7 deprecation warning(s); re-run with -deprecation for details
one warning found
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 spectralnorm 5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play