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,0002.781.3964,832707  38% 42% 29% 98%
500,0005.672.31186,736707  80% 57% 50% 62%
5,000,00027.168.59606,564707  69% 92% 75% 81%

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.


java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Clojure 1.6

 regex-dna Clojure #4 program source code

;;   The Computer Language Benchmarks Game
;; Contributed by: Alex Miller

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

(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)))
                                 (.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",
          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 (.length input))
      (println (.length sequence))
      (println @buflen)

 make, command-line, and program output logs

Wed, 19 Nov 2014 18:42:06 GMT

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

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

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


Revised BSD license

  Home   Conclusions   License   Play