Re: [android-developers] Dalvik VM Java Annotations has very poor Performance

2011-07-07 Thread Daniel Drozdzewski
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


[android-developers] Dalvik VM Java Annotations has very poor Performance

2011-07-06 Thread Bruno Vinicius
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.

My point is: there's any known deference in the implementation of
annotations from the Dalvik VM vs the standard JVM that is to blame of
such a poor performance? I must add that while the garbage collector
didn't even run on the specific/cached annotations version of my
algorithm, it triggered hundreds of times on the normal version (which
retrieved annotation info every run). Which kind of pin points where
is the problem is, but it doesn't make sence at all, as my annotations
properties consist purely on 4 string, from which 2 where empty.

Thanks in advance,
Bruno

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