Created
October 8, 2010 11:39
-
-
Save ato/616655 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
(defn microbench-lock [] | |
(let [ba (byte-array 100000000)] | |
(time (dotimes [i 80000000] (locking ba (aset ba i (byte 0))))))) | |
(dotimes [j 10] (microbench-lock)) | |
"Elapsed time: 9323.400529 msecs" | |
"Elapsed time: 9181.996864 msecs" | |
"Elapsed time: 9084.981462 msecs" | |
"Elapsed time: 9090.169757 msecs" | |
"Elapsed time: 9162.061647 msecs" | |
[... (got bored and stopped it)] | |
(defn microbench-nolock [] | |
(let [ba (byte-array 100000000)] | |
(time (dotimes [i 80000000] (aset ba i (byte 0)))))) | |
(dotimes [j 10] (microbench-nolock)) | |
"Elapsed time: 51.819095 msecs" | |
"Elapsed time: 47.302764 msecs" | |
"Elapsed time: 46.975915 msecs" | |
"Elapsed time: 46.790621 msecs" | |
"Elapsed time: 47.223832 msecs" | |
"Elapsed time: 46.95477 msecs" | |
"Elapsed time: 47.31063 msecs" | |
"Elapsed time: 47.218298 msecs" | |
"Elapsed time: 47.412488 msecs" | |
"Elapsed time: 47.326872 msecs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment