Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-10 Thread Bill James
On Feb 10, 2:47 pm, Isaac Gouy wrote: > On Feb 10, 1:17 am, Bill James wrote: > > >http://shootout.alioth.debian.org/u32/benchmark.php?test=fasta〈=all > > > The fastest program shown here is in Java and runs in 1.72 seconds. > > However, at the bottom of the page (und

Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-10 Thread Bill James
http://shootout.alioth.debian.org/u32/benchmark.php?test=fasta&lang=all The fastest program shown here is in Java and runs in 1.72 seconds. However, at the bottom of the page (under "interesting alternative" programs) there is a C++ program that runs in 0.25 seconds; it seems to work basically the

Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-07 Thread Bill James
On Feb 7, 3:47 pm, Andy Fingerhut wrote: > (defn find-index [f coll] >    (loop [i (int 0) >           s (seq coll)] >      (if (f (first s)) >        i >        (recur (unchecked-inc i) (rest s) > I didn't realize how slow my version of this was. This change alone shaves off about half a s

Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-07 Thread Bill James
Since this program eliminates so much of the work, it's disappointing that there wasn't more of a speedup. Can you (or anyone) speed it up even further? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goog

Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-06 Thread Bill James
On Feb 3, 12:22 am, Andy Fingerhut wrote: > I've done a pass through most of the Clojure programs on the shootout   > web site recently, making some of them faster, and choosing -Xmx   > command line arguments when running them to keep the memory usage down   > to a reasonable level -- not always

Re: Time/size bounded cache?

2011-02-06 Thread Bill James
On Feb 6, 2:08 pm, Seth wrote: > (filter #(= % 2)  a) Another way: (filter #{2} a) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - plea

Re: Why take-last of empty collection is nil?

2011-02-03 Thread Bill James
On Feb 3, 1:04 am, Petr Gladkikh wrote: > > And another question. I have written this function > (defn index-by >   "Make map (f x) -> x" >   [f coll] >   (reduce #(assoc %1 (f %2) %2) {} coll)) > > I wonder, is there already such function somewhere in Clojure libraries? Somewhat shorter: (defn

Re: Ridiculously massive slowdown when working with images

2011-01-31 Thread Bill James
On Jan 31, 1:33 pm, Bill James wrote: > On Jan 31, 5:46 am, B Smith-Mannschott wrote: > > > > Yes, that speeds it up considerably.  If I can get Java server > > > installed > > > on my machine, I'll post some timings. > > > What is this "ja

Re: Ridiculously massive slowdown when working with images

2011-01-31 Thread Bill James
On Jan 31, 1:40 pm, Bill James wrote: > (set! *warn-on-reflection* true) > > (def buffer-size 192) > (def array (byte-array buffer-size)) > > (defmacro add [m n] `(unchecked-add (int ~m) (int ~n))) > (defmacro uinc [m] `(unchecked-inc ~m)) > (defmacro amove[a i j]

Re: Ridiculously massive slowdown when working with images

2011-01-31 Thread Bill James
(set! *warn-on-reflection* true) (def buffer-size 192) (def array (byte-array buffer-size)) (defmacro add [m n] `(unchecked-add (int ~m) (int ~n))) (defmacro uinc [m] `(unchecked-inc ~m)) (defmacro amove[a i j] `(aset ~a ~j (aget ~a ~i))) (defn java-like0 [^bytes cpu_array] (loop [i (int

Re: Ridiculously massive slowdown when working with images

2011-01-31 Thread Bill James
On Jan 31, 5:46 am, B Smith-Mannschott wrote: > > Yes, that speeds it up considerably.  If I can get Java server > > installed > > on my machine, I'll post some timings. > > What is this "java server" of which you speak.  In JVMs I'm familiar > with (Sun/Oracle, OpenJDK) it's just a matter of p

Re: Ridiculously massive slowdown when working with images

2011-01-30 Thread Bill James
Benny Tsai wrote: > Nice! That version runs in 6 milliseconds on my machine, fastest of > all the code posted so far. One more idea: use 'unchecked-inc' > instead of 'unchecked-add'. This takes it under 3 milliseconds in my > tests. > > (defn java-like [^bytes cpu_array] > (let [buffer-size (i

Re: How to disallow unlisted optional argument keys?

2011-01-30 Thread Bill James
Alexander Yakushev wrote: > Why not use a constraint? It looks much cleaner. > > (defn hello [& {:keys [a b] :as input}] > {:pre [(= (set (keys input)) #{:a :b})]} > "hello") > > You can learn more about constraints here: > http://vimeo.com/channels/fulldisclojure#8399758 {:pre

Re: Ridiculously massive slowdown when working with images

2011-01-30 Thread Bill James
GrumpyLittleTed wrote: > Part of the difference (under 1.2) is due to the (substantial) > overhead of accessing the buffer-size var on every iteration. > > I ran a quick check and using David's version of the code result > averaged 17.2ms. Just changing buffer-size to a local with using (let > [buf

Re: Ridiculously massive slowdown when working with images

2011-01-30 Thread Bill James
David Nolen wrote: > (ns atest) > > (set! *warn-on-reflection* true) > > (def buffer-size 192) > (def array (byte-array buffer-size)) > (defn java-like [^bytes cpuArray] > (loop [i (int 0)] > (if (< i (int buffer-size)) > (let [b (byte (aget cpuArray i)) > g (byte (aget

Re: Ridiculously massive slowdown when working with images

2011-01-30 Thread Bill James
On Jan 28, 12:55 pm, David Nolen wrote: > (ns atest) > > (set! *warn-on-reflection* true) > > (def buffer-size 192) > (def array (byte-array buffer-size)) > (defn java-like [^bytes cpuArray] >   (loop [i (int 0)] >     (if (< i (int buffer-size)) >       (let [b (byte (aget cpuArray i)) >  

Re: Ridiculously massive slowdown when working with images

2011-01-30 Thread Bill James
On Jan 28, 12:55 pm, David Nolen wrote: > (ns atest) > > (set! *warn-on-reflection* true) > > (def buffer-size 192) > (def array (byte-array buffer-size)) > (defn java-like [^bytes cpuArray] >   (loop [i (int 0)] >     (if (< i (int buffer-size)) >       (let [b (byte (aget cpuArray i)) >