/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
50,000Failed  723   

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

Read regex-dna 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

 regex-dna Scala #4 program source code

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

// Contributed by The Anh Tran
// Updated for 2.8 by Rex Kerr

import scala.actors.Futures.future

object regexdna {

  def main(args: Array[String]) {
    var input = readAll
    val init_len = input length

    // strip header & newline
    input = """>.*\n|\n""".r replaceAllIn(input, "")
    val strip_len  = input length

    // counting patterns
    val patterns  = Array(
      "agggtaaa|tttaccct" ,
      "[cgt]gggtaaa|tttaccc[acg]",
      "a[act]ggtaaa|tttacc[agt]t",
      "ag[act]gtaaa|tttac[agt]ct",
      "agg[act]taaa|ttta[agt]cct",
      "aggg[acg]aaa|ttt[cgt]ccct",
      "agggt[cgt]aa|tt[acg]accct",
      "agggta[cgt]a|t[acg]taccct",
      "agggtaa[cgt]|[acg]ttaccct")

    // queue tasks, each task is handled in a separate thread
    val count_results = patterns map( pt => future(pt.r.findAllIn(input).length) )

    // replace IUB
    val replace_result = future {
    val iub = Array(
      "", "(c|g|t)", "", "(a|g|t)", "", "", "", "(a|c|t)",
      "", "", "(g|t)", "", "(a|c)", "(a|c|g|t)", "", "",
      "", "(a|g)", "(c|g)", "", "", "(a|c|g)", "(a|t)", "",
      "(c|t)"  )

      val buffer = new StringBuffer(input.length + (input.length >>> 1)) // input.len * 1.5
      val matcher = java.util.regex.Pattern compile "[BDHKMNRSVWY]" matcher input

      while ( matcher find )
        matcher appendReplacement( buffer, iub(input(matcher start) - 'A')  )

      matcher appendTail buffer
      buffer length
    }

    // print results
    for ((pt, cres) <- patterns zip count_results)
      printf( "%s %d\n", pt, cres() )

    printf( "\n%d\n%d\n%d\n", init_len, strip_len, replace_result() )
  }

  def readAll() = {
    // load data from stdin
    val reader = new java.io.InputStreamReader(System.in);

    val sb = new StringBuilder(64*1024*1024)
    val buf = new Array[Char](4 *1024*1024)
 
    Iterator.
      continually(reader read buf).
      takeWhile(_ != -1).
      foreach(n => sb.appendAll(buf, 0, n))

    sb toString
  }
}

 make, command-line, and program output logs

Wed, 19 Mar 2014 09:31:09 GMT

MAKE:
mv regexdna.scala-4.scala regexdna.scala
/usr/local/src/scala-2.10.3/bin/scalac -optimise -target:jvm-1.7 regexdna.scala
warning: there were 6 feature warning(s); re-run with -feature for details
one warning found
4.33s to complete and log all make actions

COMMAND LINE:
env JAVA_OPTS=-Xmx1024m /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 regexdna 0 < regexdna-input50000.txt

PROGRAM FAILED 


PROGRAM OUTPUT:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/actors/Future
	at regexdna$.main(regexdna.scala:32)
	at regexdna.main(regexdna.scala)
Caused by: java.lang.ClassNotFoundException: scala.actors.Future
	at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 2 more

Revised BSD license

  Home   Conclusions   License   Play