Created
December 26, 2011 22:15
-
-
Save amalloy/1522199 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
repl-1=> (defprotocol GetX (get-x [this])) | |
GetX | |
repl-1=> (defrecord Foo [x] | |
repl-1=* GetX (get-x [this] x)) | |
repl-1.Foo | |
repl-1=> (def foo (Foo. 10)) | |
#'repl-1/foo | |
repl-1=> (time (dotimes [_ 1e7] (.x ^Foo foo))) | |
"Elapsed time: 71.083148 msecs" | |
nil | |
repl-1=> (time (dotimes [_ 1e7] (get-x foo))) | |
"Elapsed time: 205.333696 msecs" | |
nil | |
repl-1=> (time (dotimes [_ 1e7] (get-x ^Foo foo))) | |
"Elapsed time: 208.352809 msecs" | |
nil | |
repl-1=> (time (dotimes [_ 1e7] (:x ^Foo foo))) | |
"Elapsed time: 346.152969 msecs" | |
nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment