On Wed, Jun 30, 2010 at 10:19 AM, j-g-faustus
<johannes.fries...@gmail.com>wrote:

> Tried the equiv branch briefly: The "1.1 style" version is ~4%
> quicker, but still ~4x slower than Java and ~2x slower than mutable
> deftype.
>
> But I found another issue: Array access apparently converts primitives
> to boxed values at every access. This is perhaps because aget/aset is
> a function and primitives cannot cross function boundaries?
> That would explain the relative slowness of arrays.
>
> Here is a test case http://gist.github.com/458669
> And a profiler screenshot
> http://i589.photobucket.com/albums/ss334/j-g-faustus/profiling/array-test-50k.png
>
> 15% CPU time goes to Double.valueOf(double) in all-primitive array
> access and another ~4% to intCast(int).
>
> The number of calls to Double.valueOf(double) seems to suggest that it
> is called only on aset, not on aget, though I can't think of any
> reason how that could be.
>
> Does anyone know more about this?
>
>
> Regards
> jf


On the equiv branch I don't see this at all. Also on the equiv branch most
of your type hints inside the fn are unnecessary.

(defn ^:static test-double ^doubles [^long n]
  (let [len  5
        arr (double-array 5)
        n    n]
    (dotimes [_ n]
      (dotimes [i len]
        (dotimes [j (inc i)]
          (aset arr j
                (+ 1.0 (- (aget arr i) (aget arr j)))))))
    arr))

David

>

-- 
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