Kabir Khan [
http://community.jboss.org/people/kabir.khan%40jboss.com] created the
discussion
"JBoss Reflect Performance Javassist vs Introspection"
To view the discussion, visit:
http://community.jboss.org/message/537409#537409
--------------------------------------------------------------
I have created a simple benchmark where I test the performance of different things using
the different implementations. It can be found at
https://svn.jboss.org/repos/jbossas/projects/jboss-reflect/trunk/src/test...
https://svn.jboss.org/repos/jbossas/projects/jboss-reflect/trunk/src/test...
It first generates 100 classes, each with 100 fields and 100 methods, then it:
* A) Obtains a ClassInfo for each class
* B) Goes through each class and calls getDeclaredField() and getDeclaredMethod() for each
field/method. This is done 50 times
* C) Calls FieldInfo.get/set and MethodInfo.get/set once for each field/method
* D) Same as C, but now it happens 50 times
Here are the times:
========== IntrospectionTypeInfoFactory
A - Creating 100 ClassInfos 141ms
B - Getting 100 fields and methods for 100 classes 50 times 1446ms
C - First accessing 100 fields and methods for 100 classes 50 times 116ms
D - Accessing 100 fields and methods for 100 classes 50 times 3545ms
Done!
========== JavassistTypeInfoFactory
A - Creating 100 ClassInfos 164ms
B - Getting 100 fields and methods for 100 classes 50 times 820ms
C - First accessing 100 fields and methods for 100 classes 50 times 4557ms
D - Accessing 100 fields and methods for 100 classes 50 times 272ms
Done!
* Creating the ClassInfos (A) takes about the same time with the two implementations.
* Calling getDeclaredMethod()/-Field() (B) is about twice as fast using Javassist as
introspection.
* The first time a joinpoint is invoked is very slow with Javassist (due to generating the
class), while subsequent calls are very fast
I'll profile C to see if it can be made faster somehow. Although, 20,000 classes are
created so my guess is that creating an output stream for the class bytes for each class
and then it with the classloader is the real overhead
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/537409#537409]
Start a new discussion in JBoss Microcontainer Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]