oblac / jodd

Jodd! Lightweight. Java. Zero dependencies. Use what you like.
https://jodd.org
BSD 2-Clause "Simplified" License
4.06k stars 724 forks source link

Question: if `Class#getAnnotation(..)` make a difference to performance? #136

Closed zqq90 closed 10 years ago

zqq90 commented 10 years ago

Hi, igor, I saw https://github.com/oblac/jodd/blob/master/jodd-madvoc/src/main/java/jodd/madvoc/component/MadvocController.java#L208

if Class#getAnnotation(..) make a difference to performance? Since getAnnotation invoked synchronized initAnnotationsIfNecessary() each time

wish a happy weekend

igr commented 10 years ago

Hey ZQQ! You are right :) However, the only solution would be to cache RenderWith annotation values with the result object classes. On the other hand, when annotation is read once, the time spend in initAnnotationsIfNecessary would be minimal.

Do you really think this could boost significantly the performance? I mean, we could add that map in result manager but i believe that it would be waste of memory vs some significant performance improvement.