Skip to content

Instantly share code, notes, and snippets.

@mdaley
Last active January 8, 2016 14:38
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 mdaley/ddf2904581328157785f to your computer and use it in GitHub Desktop.
Save mdaley/ddf2904581328157785f to your computer and use it in GitHub Desktop.
Creation of lots of Integer instances:
(time (reduce + (range 1000000)))
~ 25 - 35 ms
Using primitive types:
(time (loop [x 0 acc 0] (if (>= x 1000000) acc (recur (inc x) (+ acc x)))))
~ 3 - 4 ms (!!)
Unchecked (dangerous!) arithmetic:
(time (loop [x (int 0) acc (int 0)] (if (>= x 1000000) acc (recur (unchecked-inc x) (unchecked-add acc x)))))
~ 1.5 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment