On Tue, Jul 5, 2011 at 9:06 PM, Bruno Vinicius
<bruno.vinicius...@gmail.com> wrote:
> Hi,
>
> I've been using annotations on a Android project for a parsing XML
> data into a VO object, and I came to notice that retrieving Annotation
> info from a class or field is very slow. On a 1k iterations loop it
> gives me a 100x fold performance drop vesus a specific parsing
> algorithm version. Caching the annotation data on the first run, gave
> me results very close (~10ms diference) on the specific algorithm
> version.

Bruno,

any chance to see the code of all 3 versions (annotated, annotated &
cached, and specific parsing) ?
If the parsing is specific to your problem, then it is bound to be
quicker, as otherwise you pay for universality.

Annotations per se should not hit the performance, the same way that
static class members or methods don't hit the performance.
It is what happens to those annotations. They annotate various parts
of your code, so that some processing based on that metadata can be
done. They are essentially markers helping to find code, for whatever
reason and whatever processing.

They can be processed at compile time, which is probably what you
should do with your parser, but it will depend on the parsing
technology you use. How are the annotations that you use defined (each
annotation has retention policy).

Have a look at Annotation Processing Tool (apt), that comes with Java
JDK 5. In JDK 6 it is a part of the compiler. It should help you
generate the code at compile time, so you would not be hit by runtime
reflection and introspecting.

...but it's all speculations as the problem of performance is quite
complex and multi-layered as you can imagine


The best solution to XML parsing is to use parsers that are geared
towards mobile platforms.


Daniel

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to