Created
May 4, 2012 23:53
-
-
Save michalmarczyk/2598523 to your computer and use it in GitHub Desktop.
Benchmarks for CLJS protocol dispatch
This file contains hidden or 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
(ns timings) | |
(defn -main [] | |
(println ";;; satisfies?") | |
(println "(satisfies? ISeq (list 1 2 3))") | |
(let [coll (list 1 2 3)] (time (dotimes [_ 10000000] (satisfies? ISeq coll)))) | |
(println "(satisfies? ISeq [1 2 3])") | |
(let [coll [1 2 3]] (time (dotimes [_ 10000000] (satisfies? ISeq coll)))) | |
(println) | |
(println ";;; list ops") | |
(println "(first (list 1 2 3))") | |
(let [coll (list 1 2 3)] (time (dotimes [_ 1000000] (first coll)))) | |
(println "(-first (list 1 2 3))") | |
(let [coll (list 1 2 3)] (time (dotimes [_ 1000000] (-first coll)))) | |
(println "(rest (list 1 2 3))") | |
(let [coll (list 1 2 3)] (time (dotimes [_ 1000000] (rest coll)))) | |
(println "(next (list 1 2 3))") | |
(let [coll (list 1 2 3)] (time (dotimes [_ 1000000] (next coll)))) | |
(println) | |
(println ";;; vector ops") | |
(println "(first [1 2 3])") | |
(let [coll [1 2 3]] (time (dotimes [_ 1000000] (first coll)))) | |
(println "(rest [1 2 3])") | |
(let [coll [1 2 3]] (time (dotimes [_ 1000000] (rest coll)))) | |
(println "(next [1 2 3])") | |
(let [coll [1 2 3]] (time (dotimes [_ 1000000] (next coll)))) | |
(println) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment