Last active
August 29, 2015 14:19
-
-
Save pbalduino/873f25c2f4a797c30f1a to your computer and use it in GitHub Desktop.
Primitive
This file contains hidden or 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
| (def numeros (range 0 10000)) | |
| (def vetor (into-array Long/TYPE numeros)) | |
| (defmacro benchmark [code] | |
| `(time (first (doall (repeatedly 1000 (fn [] ~code)))))) | |
| (benchmark (reduce + numeros)) | |
| ; "Elapsed time: 123.946807 msecs" | |
| (benchmark (reduce + vetor)) | |
| ; "Elapsed time: 443.06224 msecs" | |
| (benchmark (areduce ^longs vetor | |
| idx | |
| ret | |
| 0 | |
| (MinhaClasse/soma ret | |
| ^long (aget ^longs vetor idx)))) | |
| ; "Elapsed time: 66.865549 msecs msecs" | |
| (benchmark (MinhaClasse/somaArray ^longs vetor)) | |
| ; "Elapsed time: 39.833578 msecs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment