Hello

words is not of a primitive type. Try:

(defn shorts-to-bytes [#^shorts src #^bytes dst words]
  (let [words (int words)]
    (loop [src-offset (int 0)
           dst-offset (int 0)]
      (when (< src-offset words)
        (let [sample (short (aget src src-offset))]
          (aset dst dst-offset (byte sample))
          (aset dst (unchecked-inc dst-offset) (byte (bit-shift-right sample
8))))
        (recur (unchecked-inc src-offset) (unchecked-add 2 dst-offset))))))


On Mon, Sep 7, 2009 at 12:25 AM, icemaze<icem...@gmail.com> wrote:
>
> Nicholas,
> thank you for your reply. I applied the change you suggested.
> Unfortunately it skimmed only about 50ms from each exectuion.
>
> Even though I'm using aset, java.lang.reflect.Array.setByte *still*
> uses ~25% of execution time. This means two things: A) Reflection is
> still used for this code. B) Even if we could reduce reflection to
> zero, Clojure would still be the underdog, by far.
>
> Undated benchmark:
>
> "Elapsed time: 465.620154 msecs"
> "Elapsed time: 5.256433 msecs"
>
> "Elapsed time: 465.751133 msecs"
> "Elapsed time: 3.377667 msecs"
>
> "Elapsed time: 472.59319 msecs"
> "Elapsed time: 3.117197 msecs"
>
> "Elapsed time: 478.251893 msecs"
> "Elapsed time: 3.422244 msecs"
>
> >
>



-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (en)

--~--~---------~--~----~------------~-------~--~----~
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 - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to