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
2,000Failed  355   

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

Read pidigits 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

 pidigits Scala program source code

/* 
 * The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 * contributed by Joseph Tang
*/

import math._

def pi(n: Int) = {
  val pr = 1.0 / pow(10, n)
  def t(initial: BigDecimal = 2, i: Int = 0): Int = {
    val current = (i + 1) * 1.0 / (2 * i + 3) * initial
    if (current < pr) i else t(current, i + 1)
  }
  val ts = t()
  def calPi(i: Int): BigDecimal = if (i > ts) 2.5 else 2 + i * calPi(i + 1) / (2 * i + 1)
  calPi(1)
}

def p10(s: String, offset: Int = 0) {
  val (s1, r) = s.splitAt(10)
  println(s"$s1\t:${offset + s1.length}")
  if (!r.isEmpty) p10(r, 10 + offset)
}

val n = if (args.isEmpty) 27 else args(0).toInt
p10(pi(n).toString().filterNot(_ == '.').substring(0, n))

 make, command-line, and program output logs

Wed, 19 Nov 2014 08:18:34 GMT

MAKE:
mv pidigits.scala pidigits.scala
mv: ‘pidigits.scala’ and ‘pidigits.scala’ are the same file
make: [pidigits.scala_run] Error 1 (ignored)
/usr/local/src/scala-2.11.4/bin/scalac -optimise -target:jvm-1.8 pidigits.scala
pidigits.scala:9: error: expected class or object definition
def pi(n: Int) = {
^
pidigits.scala:20: error: expected class or object definition
def p10(s: String, offset: Int = 0) {
^
pidigits.scala:26: error: expected class or object definition
val n = if (args.isEmpty) 27 else args(0).toInt
^
pidigits.scala:27: error: expected class or object definition
p10(pi(n).toString().filterNot(_ == '.').substring(0, n))
^
four errors found
make: [pidigits.scala_run] Error 1 (ignored)
1.30s to complete and log all make actions

COMMAND LINE:
 /usr/local/src/jdk1.8.0_25/bin/java -server -XX:+TieredCompilation -XX:+AggressiveOpts -Djava.library.path=Include/java -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 pidigits 2000

PROGRAM FAILED 


PROGRAM OUTPUT:

Error: Could not find or load main class pidigits

Revised BSD license

  Home   Conclusions   License   Play