Skip to content

Instantly share code, notes, and snippets.

@pbalduino
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save pbalduino/873f25c2f4a797c30f1a to your computer and use it in GitHub Desktop.

Select an option

Save pbalduino/873f25c2f4a797c30f1a to your computer and use it in GitHub Desktop.
Primitive
(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