Last active
December 19, 2015 13:49
-
-
Save fbmnds/5964948 to your computer and use it in GitHub Desktop.
Iota performance profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[iota] | |
'[clojure.core.reducers :as r]) | |
(def test-file "/path/to/test-file") | |
(def test-vec (iota/vec test-file)) | |
(defn f [m] | |
(let [rem (:remaining m)] | |
(cond (nil? rem) {:end true} | |
(= 1 (count rem)) {:yield "OK"} | |
:else {:remaining (rest rem)}))) | |
(defn parse [f coll] | |
(->> coll | |
(iterate f) | |
(take-while #(not (contains? % :end))) | |
(map :yield) | |
(filter #(not (nil? %))))) | |
(defn make-m [coll] (hash-map :remaining coll)) | |
(defn measure [f n seq] | |
(time (first (parse f (make-m (take n seq)))))) | |
(comment | |
;; state map manipulation eats up the performance again: | |
;; | |
user> (measure f 10 test-vec) | |
"Elapsed time: 2.83674 msecs" | |
"OK" | |
;; | |
;; I ignore the performance effect on the first run, | |
;; take the fast second run for printing | |
;; | |
user> (measure f 10 test-vec) | |
"Elapsed time: 0.163395 msecs" | |
"OK" | |
user> (measure f 20 test-vec) | |
"Elapsed time: 0.349032 msecs" | |
"OK" | |
user> (measure f 30 test-vec) | |
"Elapsed time: 0.580437 msecs" | |
"OK" | |
user> (measure f 40 test-vec) | |
"Elapsed time: 0.835367 msecs" | |
"OK" | |
user> (measure f 50 test-vec) | |
"Elapsed time: 0.819113 msecs" | |
"OK" | |
user> (measure f 60 test-vec) | |
"Elapsed time: 1.006033 msecs" | |
"OK" | |
user> (measure f 70 test-vec) | |
"Elapsed time: 1.179694 msecs" | |
"OK" | |
user> (measure f 80 test-vec) | |
"Elapsed time: 1.388001 msecs" | |
"OK" | |
user> (measure f 90 test-vec) | |
"Elapsed time: 1.889734 msecs" | |
"OK" | |
user> (measure f 100 test-vec) | |
"Elapsed time: 1.627105 msecs" | |
"OK" | |
user> (measure f 1000 test-vec) | |
"Elapsed time: 63.686888 msecs" | |
"OK" | |
user> (measure f 2000 test-vec) | |
"Elapsed time: 238.173208 msecs" | |
"OK" | |
user> (measure f 4000 test-vec) | |
"Elapsed time: 866.329525 msecs" | |
"OK" | |
user> (measure f 6000 test-vec) | |
"Elapsed time: 1996.374938 msecs" | |
"OK" | |
user> (measure f 8000 test-vec) | |
"Elapsed time: 3399.983575 msecs" | |
"OK" | |
user> (measure f 10000 test-vec) | |
"Elapsed time: 5454.232469 msecs" | |
"OK" | |
user> (measure f 20000 test-vec) | |
"Elapsed time: 23294.108664 msecs" | |
"OK" | |
user> (measure f 40000 test-vec) | |
"Elapsed time: 149430.598347 msecs" | |
"OK" | |
user> (measure f 60000 test-vec) | |
"Elapsed time: 349269.364568 msecs" | |
"OK" | |
user> (measure f 80000 test-vec) | |
"Elapsed time: 578910.637408 msecs" | |
"OK" | |
user> (measure f 100000 test-vec) | |
"Elapsed time: 1025572.312396 msecs" | |
"OK" | |
) | |
(def n '(10 20 30 40 50 60 70 80 90 100 200 300 400 500 600 700 800 900 1000)) | |
(def t-in-ms-iota '(0.163395 0.349032 0.580437 0.835367 0.819113 1.006033 1.179694 1.388001 1.889734 1.627105 4.430481 8.102588 13.409071 19.751101 25.902361 34.728677 42.501053 52.27352 63.496008)) | |
(defn norm [s1 s2] (map #(/ (% 1) (% 0)) (for [i (range (count s1))] [(nth s1 i) (nth s2 i)]))) | |
(use '(incanter core stats charts)) | |
;; name mapping for the plot legend: | |
;; | |
(def clj-java-1-5-1-iota (norm n t-in-ms-iota)) | |
;; | |
(doto | |
(xy-plot n | |
clj-java-1-5-1-iota | |
:title "Throughput by Volume" | |
:x-label "number of lines" | |
:y-label "runtime per line (ms)" | |
:legend true) | |
(set-stroke-color java.awt.Color/blue :series 0) | |
view) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment