Created
March 11, 2013 18:56
-
-
Save pjstadig/5136670 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
Clojure 1.5.0-beta7 | |
user=> (def the-atom (atom 0)) | |
#'user/the-atom | |
user=> (def the-ref (ref 0)) | |
#'user/the-ref | |
user=> (defn use-atom [] (swap! the-atom inc)) | |
#'user/use-atom | |
user=> (defn use-ref [] (dosync (commute the-ref inc))) | |
#'user/use-ref | |
user=> (time (dotimes [_ 10000000] (use-atom))) | |
"Elapsed time: 305.798562 msecs" | |
nil | |
user=> (time (dotimes [_ 10000000] (use-ref))) | |
"Elapsed time: 6823.719408 msecs" | |
nil | |
user=> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment