/mobile Handheld Friendly website

 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
100.870.8118,940459  1% 99% 4% 9%
117.557.5019,048459  1% 1% 97% 3%
12100.61100.5518,988459  0% 1% 100% 0%

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

Read fannkuch-redux 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

 fannkuch-redux Scala program source code

/* The Computer Language Benchmarks Game
   http://benchmarksgame.alioth.debian.org/

   conversion to Scala by Rex Kerr
   from Java version by Oleg Mazurov and Isaac Gouy
*/

object fannkuchredux
{
  def fannkuch(n: Int): Int = {
    val perm1 = Array.range(0,n)
    val perm, count = new Array[Int](n)
    var f, i, k, r, flips, nperm, checksum = 0

    r = n
    while (r>0) {
      i = 0
      while (r != 1) { count(r-1) = r; r -= 1 }
      while (i < n) { perm(i) = perm1(i); i += 1 }
      
      // Count flips and update max  and checksum
      f = 0
      k = perm(0)
      while (k != 0) {
        i = 0
        while (2*i < k) {
          val t = perm(i); perm(i) = perm(k-i); perm(k-i) = t
          i += 1
        }
        k = perm(0)
        f += 1
      }
      if (f>flips) flips = f
      if ((nperm&0x1)==0) checksum += f
      else checksum -= f

      // Use incremental change to generate another permutation
      var go = true
      while (go) {
        if (r == n) {
          println(checksum)
          return flips
        }
        val p0 = perm1(0)
        i = 0
        while (i < r) {
          val j = i+1
          perm1(i) = perm1(j)
          i = j
        }
        perm1(r) = p0

        count(r) -= 1
        if (count(r) > 0) go = false
        else r += 1
      }
      nperm += 1
    }
    flips
  }

  def main(args: Array[String]) {
    val n = (if (args.length > 0) args(0).toInt else 7)
    println("Pfannkuchen("+n+") = "+fannkuch(n))
  }
}

 make, command-line, and program output logs

Wed, 19 Mar 2014 06:49:28 GMT

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

PROGRAM OUTPUT:
3968050
Pfannkuchen(12) = 65

Revised BSD license

  Home   Conclusions   License   Play