Last active
June 18, 2017 17:55
-
-
Save rauhs/b5b713f9cdecf351b1179e823f12164b to your computer and use it in GitHub Desktop.
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
Note: apply-old includes the optimized to-array of CLJS-2100 | |
"Datastructure: Set" | |
(apply-old f args), 1000000 runs, 716 msecs | |
(apply f args), 1000000 runs, 225 msecs | |
(apply-old f args), 1000000 runs, 641 msecs | |
(apply f args), 1000000 runs, 184 msecs | |
"Single arity fn, like JS fn" | |
(apply-old f 1 2 3 4 args), 1000000 runs, 903 msecs | |
(apply f 1 2 3 4 args), 1000000 runs, 358 msecs | |
(apply-old f 1 2 3 4 args), 1000000 runs, 870 msecs | |
(apply f 1 2 3 4 args), 1000000 runs, 362 msecs | |
"Multi arity fn" | |
(apply-old f 1 2 args), 1000000 runs, 697 msecs | |
(apply f 1 2 args), 1000000 runs, 181 msecs | |
(apply-old f 1 2 args), 1000000 runs, 687 msecs | |
(apply f 1 2 args), 1000001 runs, 164 msecs | |
"Normal function 1 arg" | |
(apply-old f args), 1000000 runs, 480 msecs | |
(apply f args), 1000000 runs, 194 msecs | |
(apply-old f args), 1000000 runs, 483 msecs | |
(apply f args), 1000000 runs, 194 msecs | |
"Normal function 20 arg" | |
(apply-old f args), 100000 runs, 196 msecs | |
(apply f args), 100000 runs, 89 msecs | |
(apply-old f args), 100000 runs, 196 msecs | |
(apply f args), 100000 runs, 89 msecs |
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
(enable-console-print!) | |
(defn f20 | |
[a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19] | |
(+ a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19)) | |
(defn f21 | |
[a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20] | |
(+ a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20)) | |
(apply f20 (repeat 20 1)) | |
(apply f21 1 (repeat 20 1)) | |
#_(apply f21 1 1 1 1 1 1 (repeat 15 1)) | |
(defn single-arity-fn | |
[a b c] | |
(+ a b c)) | |
(defn m-arity-fn | |
([a b c] | |
(+ a b c)) | |
([a b c d] | |
(+ a b c d))) | |
;#_ | |
(when true | |
(do | |
(prn "Datastructure: Set") | |
(let [n 3 | |
sims 1000000 | |
f #{:a} | |
args [:a :b]] | |
(dotimes [_ 2] | |
(simple-benchmark | |
[] | |
(apply-old f args) | |
sims) | |
(simple-benchmark | |
[] | |
(apply f args) | |
sims))) | |
(prn "Single arity fn, like JS fn") | |
(let [n 3 | |
sims 1000000 | |
f single-arity-fn | |
args [] #_(vec (range n))] | |
(dotimes [_ 2] | |
(simple-benchmark | |
[] | |
(apply-old f 1 2 3 4 args) | |
sims) | |
(simple-benchmark | |
[] | |
(apply f 1 2 3 4 args) | |
sims))) | |
(prn "Multi arity fn") | |
(let [sims 1000000 | |
f m-arity-fn | |
args (vec (range 2))] | |
(dotimes [_ 2] | |
(simple-benchmark | |
[] | |
(apply-old f 1 2 args) | |
sims) | |
(simple-benchmark | |
[] | |
(apply f 1 2 args) | |
sims))) | |
(prn "Normal function 1 arg") | |
(let [n 3 | |
sims 1000000 | |
f single-arity-fn | |
args (vec (range n))] | |
(dotimes [_ 2] | |
(simple-benchmark | |
[] | |
(apply-old f args) | |
sims) | |
(simple-benchmark | |
[] | |
(apply f args) | |
sims))) | |
(prn "Normal function 20 arg") | |
(let [n 20 | |
sims 100000 | |
f f20 | |
args (vec (range n))] | |
(dotimes [_ 2] | |
(simple-benchmark | |
[] | |
(apply-old f args) | |
sims) | |
(simple-benchmark | |
[] | |
(apply f args) | |
sims))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment