Skip to content

Instantly share code, notes, and snippets.

@acardona
Created November 30, 2011 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acardona/1409021 to your computer and use it in GitHub Desktop.
Save acardona/1409021 to your computer and use it in GitHub Desktop.
(ns my.numeric.test
(:import [fiji.scripting Weaver]))
(def a (ref nil))
; Compile once
(def w (Weaver/inline
"int n = ((Number)ref.deref()).intValue();
double sum = 0;
for (int i=0; i<n; ++i) {
sum += Math.random();
}
return sum;"
{"ref" a}
Double true))
; Run many times by altering 'a' to new numbers (here the same is used every time)
(println
(dotimes [i 10]
(dosync (alter a (fn [_] 300000)))
(time (.call w))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment