1 Feb 2011 01:33
Re: Ridiculously massive slowdown when working with images
Bill James <w_a_x_man <at> yahoo.com>
2011-02-01 00:33:10 GMT
2011-02-01 00:33:10 GMT
On Jan 31, 1:40 pm, Bill James <w_a_x_... <at> yahoo.com> wrote: > (set! *warn-on-reflection* true) > > (def buffer-size 1920000) > (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 0)] > (if (< i (int buffer-size)) > (let [b (byte (aget cpu_array i)) > g (byte (aget cpu_array (unchecked-add i (int 1)))) > r (byte (aget cpu_array (unchecked-add i (int 2)))) > a (byte (aget cpu_array (unchecked-add i (int 3))))] > (aset cpu_array i a) > (aset cpu_array (unchecked-add i (int 1)) b) > (aset cpu_array (unchecked-add i (int 2)) g) > (aset cpu_array (unchecked-add i (int 3)) r) > (recur (unchecked-add i (int 4))))))) > > ;;; Make buffer-size a local. > (defn java-like1 [^bytes cpu_array] > (let [buffer-size (int buffer-size)] > (loop [i (int 0)] > (if (< i (int buffer-size)) > (let [b (byte (aget cpu_array i)) > g (byte (aget cpu_array (unchecked-add i (int 1))))(Continue reading)
RSS Feed