/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this Clojure program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
50,0003.161.4757,868707  27% 50% 46% 98%
500,0006.002.41120,800707  56% 58% 51% 86%
5,000,00028.529.02634,928707  72% 75% 72% 97%

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)

Clojure 1.6.0

 regex-dna Clojure #4 program source code

;;   The Computer Language Benchmarks Game
;;   http://benchmarksgame.alioth.debian.org/
;;
;; Contributed by: Alex Miller

(ns regexdna
  (:import [java.io FileInputStream FileDescriptor]
           [java.nio ByteBuffer]
           [java.util.regex Pattern])
  (:gen-class))

(set! *warn-on-reflection* true)
(set! *unchecked-math* true)

(defn -main [& args]
  (let [cin (-> FileDescriptor/in FileInputStream. .getChannel)
        bb (-> cin .size int ByteBuffer/allocate)]
    (.read cin bb)
    (let [input (String. (.array bb) "US-ASCII")
          sequence (.replaceAll input ">.*\n|\n" "")
          replacements (array-map "B" "(c|g|t)"
                                  "D" "(a|g|t)"
                                  "H" "(a|c|t)"
                                  "K" "(g|t)"
                                  "M" "(a|c)"
                                  "N" "(a|c|g|t)"
                                  "R" "(a|g)"
                                  "S", "(c|g)"
                                  "V", "(a|c|g)"
                                  "W", "(a|t)"
                                  "Y", "(c|t)")
          buflen (future-call #(let [buf (StringBuffer.)
                                     m (.matcher (Pattern/compile "[WYKMSRBDVHN]") sequence)]
                                 (loop []
                                   (when (.find m)
                                     (.appendReplacement m buf "")
                                     (.append buf (get replacements (.group m)))
                                     (recur)))
                                 (.appendTail m buf)
                                 (.length buf)))
          variants ["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"]
          match-fn (fn [^String v]
                     (let [m (.matcher (Pattern/compile v) sequence)]
                       (loop [c 0]
                         (if (.find m)
                           (recur (inc c))
                           [v c]))))
          results (pmap match-fn variants)]
      (doall (for [[variant c] results] (println variant c)))
      (println)
      (println (.length input))
      (println (.length sequence))
      (println @buflen)
      (shutdown-agents))))

 make, command-line, and program output logs

Sat, 19 Apr 2014 02:00:36 GMT

MAKE:
mv regexdna.clojure-4.clojure regexdna.clj
/usr/local/src/jdk1.8.0/bin/java -Dclojure.compile.path=. -cp .:/usr/local/src/clojure/clojure-1.6.0.jar clojure.lang.Compile regexdna
Compiling regexdna to .
1.66s to complete and log all make actions

COMMAND LINE:
/usr/local/src/jdk1.8.0/bin/java -server -XX:+TieredCompilation -XX:+AggressiveOpts -Xmx1024m -cp .:/usr/local/src/clojure/clojure-1.6.0.jar regexdna 0 < regexdna-input5000000.txt

PROGRAM OUTPUT:
agggtaaa|tttaccct 356
[cgt]gggtaaa|tttaccc[acg] 1250
a[act]ggtaaa|tttacc[agt]t 4252
ag[act]gtaaa|tttac[agt]ct 2894
agg[act]taaa|ttta[agt]cct 5435
aggg[acg]aaa|ttt[cgt]ccct 1537
agggt[cgt]aa|tt[acg]accct 1431
agggta[cgt]a|t[acg]taccct 1608
agggtaa[cgt]|[acg]ttaccct 2178

50833411
50000000
66800214

Revised BSD license

  Home   Conclusions   License   Play