On Aug 15, 9:45 am, Nicolas Oury <nicolas.o...@gmail.com> wrote:
> Thank you very much for your answers.
> The syntax was difficult to guess.
> Is there a general rule for forming the internal name of types?
>
> It seems after a few tests that is is slightly slower (15-20%) than
> making a final static function:
>
> static final A arrayAccess (A [] array, int i)
> { return array[i]}
>
> and calling it.
>
> and similar in speed to:
> static final Object arrayAccess (Object [] array, int i)
> { return array[i]}
>
> Am I wrong if I deduce that this is not specialized on the type?
>
> I use it in  a tight loop that does not much inside each loop, so the
> type checks do not seem to be negligible.
>
> I guess that's the price of trying to write solutions to not very
> interesting micro-benchmark :).
>
> Best regards,
>
> Nicolas.
>
> On Sat, 2009-08-15 at 12:06 -0400, David Nolen wrote:
> > You need to specify the array type. For example the following produces
> > a primitive array of n javax.vecmath.Vector2d elements.
>
> > (defn #^"[Ljavax.vecmath.Vector2d;" point-array [n]
> >   (make-array javax.vecmath.Vector2d n))
>
> > It works. If you want to see it in action take a look at:
>
> >http://github.com/swannodette/convex-hull/tree/master
>
> > On Sat, Aug 15, 2009 at 11:41 AM, Nicolas Oury
> > <nicolas.o...@gmail.com> wrote:
>
> >         Dear all,
>
> >         I try to write a program where I access a java array of non
> >          primitive
> >         and realize aget is very slow.
> >         (6x slower than the same program with clojure vectors instead
> >         of java
> >         arrays access)
>
> >         I tried a few combinations of type hints but can't manage to
> >         prevent mty
> >         program to spend most of its time there:
>
> >         99.4%     0  +  8804    java.lang.reflect.Array.get
>
> >         Does anyone know how to speed that up?
> >         Is it written somewhere in the java interop documentation?
>
> >         Best,
>
> >         Nicolas.

I don't know if this works for all classes, but you can try this:

user> (class (make-array java.lang.Object 5))
[Ljava.lang.Object;

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