Skip to content

Instantly share code, notes, and snippets.

@domgetter
Created December 14, 2015 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domgetter/5118978273fc61cceb69 to your computer and use it in GitHub Desktop.
Save domgetter/5118978273fc61cceb69 to your computer and use it in GitHub Desktop.
;; Timings are after the JVM had done all possible optimizations
(defn asdf [a b] (+ a b))
(dotimes [x 1000] (time (dotimes [x 1000000] (+ 2 3)))) ;; "Elapsed time: 0.280724 msecs"
(dotimes [x 1000] (time (dotimes [x 1000000] (asdf 2 3)))) ;; "Elapsed time: 1.114747 msecs"
(defn asdf ^long [^long a ^long b] (+ a b))
(dotimes [x 1000] (time (dotimes [x 1000000] (+ 2 3)))) ;; "Elapsed time: 0.280724 msecs"
(dotimes [x 1000] (time (dotimes [x 1000000] (asdf 2 3)))) ;; "Elapsed time: 0.57473 msecs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment